一个小问题是,我创建了一个自定义的UITablecell,但是在单元中它需要解析数据,所以我将IBOutlet UILabel *One;连接到一个UILabel,但是当我这样做时
One.text = @"Lorem...";错误显示我在mijn viewController中导入了UITablecell.h。
**Use of undeclared identifier 'One'**/
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
ViewControllerCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray* views = [[NSBundle mainBundle] loadNibNamed:@"ViewControllerCell" owner:nil options:nil];
for (UIView *view in views) {
if([view isKindOfClass:[UITableViewCell class]])
{
cell = (ViewControllerCell*)view;
}
}
}
One.text = @"Lorem...";
return cell;
}发布于 2012-04-29 00:25:56
在本例中,您的自定义UITableViewCell类的实例将是cell,因此您需要像这样访问它
cell.One.text = @"Lorem..";发布于 2012-05-14 20:58:44
首先,您必须将tableViewCell类型转换为您的自定义单元格。
{
YourCustomCell *objCustomCell=(YourCustomCell *)[tableView cellForRowAtIndexPath:indexPathForThatRow];
objCustomCell.One.text=@"YourDesiredstringvalue";
}https://stackoverflow.com/questions/10365290
复制相似问题