【发布时间】:2012-08-15 12:30:44
【问题描述】:
我有一个UITableView,我在界面生成器中使用自定义UITableViewCell 进行填充。我在访问这些自定义 tableviewcells 属性时遇到了一些问题,希望能得到一些帮助。
在 Interface Builder 中,我将自定义 tableviewcell 的 class 设置为当前 View 控制器(因此我可以将所有标签对象分配给 Interface Builder 中的正确标签),因此我还设置了 IBOutlet 标签到 Interface Builder 中的正确标签 但是,当我尝试将 NSString 从数组对象变量(类型为 NSString)传递到 UIlabel 的文本时,会发生此错误。
Property 'cellDescription' not found on object of type 'UITableViewCell *'
下面是我用自定义 tableviewcell 设置我的 tableview 的代码,然后尝试用正确的文本填充单元格 UILabels..
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (indexPath.section == 0) {
// Set cell height
[self tableView:tableView heightForRowAtIndexPath:indexPath];
// Configure the cell using custom cell
[[NSBundle mainBundle] loadNibNamed:@"AutomotiveSearchCell" owner:self options:nil];
cell = autoSearchCell;
//call dataArrayOfObject that has all of the values you have to apply to the custom tableviewcell
SearchResultItem* myObj = (SearchResultItem*)[dataArrayOfObjects objectAtIndex:indexPath.row];
cell.cellDescription.text = myObj.seriesDescription; // This is where I am receiving the error
NSLog(@"%@", myObj.seriesDescription); // This logs the correct value
//Disclosure Indicator
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
return cell;
}
【问题讨论】:
标签: iphone ios uitableview