【发布时间】:2014-05-19 11:15:28
【问题描述】:
使用UITableView 发现cells 没有正确出列。我使用storyboard 创建了原型单元格,并在单元格上设置了UIlabel。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"cell";
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell==nil) {
cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
UILabel*textLabel = (UILabel*)[cell viewWithTag:11];
textLabel.font=[UIFont fontWithName:@"MyUnderwood" size:16];
textLabel.text = [_tableLabelArray objectAtIndex:indexPath.row];
return cell;
}
这是我滚动TableView时得到的UITableView的图像
【问题讨论】:
-
这是你的真实代码吗?因为没有使用textLabel,也没有多大意义。似乎也没有错。您的自定义单元格中有 uilabel 吗?
-
您是否偶然在原型单元格中拥有多个具有相同标签的 UILabel?
-
@Justafinger 是的,我的自定义单元格中有 UILabel。
-
如果您有该方法的真实/完整代码,那就太好了。
标签: ios uitableview storyboard