UITableView中缺少单元格

时间:2015-03-09 06:36:51

标签: ios objective-c uitableview

我正在使用标签库XLPagerTabStrip

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

如果我添加该行,我就看不到该单元格。单元格不是以编程方式创建的,而是在故事板中创建的。

图书馆有一个错误:http://github.com/xmartlabs/XLPagerTabStrip/issues/10

如何让细胞显示? 或者标签库XLPagerTabStrip还有什么好的选择吗?

1 个答案:

答案 0 :(得分:0)

您可以在cellForRowAtIndexPath上使用以下代码进行自定义单元格

static NSString *CellIdentifier = @"StoryBoardCellIdentifier";

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

// OR用于默认的UITableView Cell - >故事板上的Proto Type Cell

static NSString *CellIdentifier = @"UserInfoBasicCell";

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

希望它可以帮助你......!

相关问题