我在没有Storyboard帮助的情况下创建了UITableViewController。
我已获得以下代码:
- (void)viewDidLoad {
[super viewDidLoad];
self.cellReuseIdentifier = @"myViewControllerCellReuseIdentifier";
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:self.cellReuseIdentifier];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:self.cellReuseIdentifier forIndexPath:indexPath];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:self.cellReuseIdentifier];
}
}
在这种情况下,细胞样式不存在。我该如何解决这个问题?
答案 0 :(得分:-1)
我想如果您只是添加UITableView,请将您的viewcontroller设置为委托和数据源,这就足够了。如果在cellForRowAtIndexPath中设置断点,它会触发吗?
不确定你在做什么,
$PATH
而是这样做,
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:self.cellReuseIdentifier];
如果这不是你想要的,请告诉我,祝你好运。