【问题标题】:Cell missing in the UITableViewUITableView 中缺少单元格
【发布时间】:2015-03-09 06:36:51
【问题描述】:

我正在使用标签库XLPagerTabStrip

如果我不添加此行:[self.tableView registerClass:[UserInfoBasicCell class] forCellReuseIdentifier:kCellIdentifierBasicCell]; 它在 cellForRowAtIndexPath 处崩溃:[tableView dequeueReusableCellWithIdentifier:kCellIdentifierBasicCell forIndexPath:indexPath];

如果我添加该行,我将看不到单元格。单元格不是通过程序创建的,它是在情节提要中创建的。

库有一个bug:http://github.com/xmartlabs/XLPagerTabStrip/issues/10

如何让单元格显示? 或者标签库XLPagerTabStrip有什么好的替代品吗?

【问题讨论】:

  • 我也试过了,但是不行。
  • 你在哪里添加了那个方法?在 viewDidLoad 或 cellForRowAtIndexPath: 中?试试Set reuse identifiers in storyboard 而不是 registerNib ?
  • 情节提要中的表格、我设置的单元格和类集是如何定义的?
  • 确保 kCellIdentifierBasicCell 的值与您在情节提要中为单元重用标识符提供的值相同。

标签: ios objective-c uitableview


【解决方案1】:

您可以在 cellForRowAtIndexPath 处为自定义单元格使用以下代码

static NSString *CellIdentifier = @"StoryBoardCellIdentifier";

        UserInfoBasicCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil){
            cell = [[UserInfoBasicCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        }

//默认 UITableView 单元格-->情节提要中的原型单元格

static NSString *CellIdentifier = @"UserInfoBasicCell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

希望对你有所帮助..!

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-11-12
  • 1970-01-01
相关资源
最近更新 更多