我在 UIViewController
中有 UITableView
,并通过 socket 进行连接,并将委托(delegate)和数据源分配给 self.numberOfSectionsInTableView
和 numberOfRowsInSection
正在被调用,我尝试使用 NSLog
但 cellForRowAtIndexPath
没有被调用,我的代码看起来像
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@" cellForRowAtIndexPath ");
static NSString *CellIdentifier = @"CurrencyCell";
CurrencyCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[CurrencyCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] ;
}
new *Obj = [appdelegate.array objectAtIndex:indexPath.row];
cell.CurNameLabel.text = Obj.C_Name;
cell.textLabel.text = @"sdfnhsdfndsio;";
NSLog(@"C_Name %@", Obj.C_Name);
return cell;
}
任何人都可以告诉我我犯了错误吗?提前致谢
最佳答案
返回的numberOfSectionsInTableView
和numberOfRowsInSection
似乎是0。如果是这种情况,则不会调用cellForRowAtIndexPath。
从上面的评论来看......似乎“YourAppDelegate”变量为null
或yourArray为null
。尝试在这些委托(delegate)上保留断点,以检查值由他们返回
关于iphone - - TableView :cellForRowAtIndexPath: is not getting called,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12972452/