首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >TableViewCell的textLabel和detailTextLabel无法正常工作

TableViewCell的textLabel和detailTextLabel无法正常工作
EN

Stack Overflow用户
提问于 2013-09-10 13:31:05
回答 2查看 628关注 0票数 2

命令cell.textLabel.text和cell.detailTextLabel.text在控制台中提供输出,但在模拟器的表视图上没有给出任何值...

这是生成我所使用的单元格的代码。

代码语言:javascript
运行
复制
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"bookCell";
    UITableViewCell *cell;
    cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];

  // Book *bookDetail=[booksArrayDataSource objectAtIndex:indexPath.row];


    cell.accessoryType=UITableViewCellAccessoryDetailDisclosureButton;

    cell.textLabel.text= [self titleForRow:indexPath];
    NSLog(@"title for row= %@", cell.textLabel.text);

    cell.detailTextLabel.text= [self subtitleForRow:indexPath];
    NSLog(@"subtitle for row= %@",cell.detailTextLabel.text);

    return cell;
}
EN

Stack Overflow用户

发布于 2013-09-10 17:33:02

转到情节提要/xib并将单元格类型从dynamic更改为subtitle。

无论您在这里拥有什么,都不会被执行:

代码语言:javascript
运行
复制
if (cell == nil)
{
...
}
票数 0
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18711318

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档