【发布时间】:2012-10-19 10:34:33
【问题描述】:
我在UIViewController 中有UITableView,并且我已经通过插座连接,并且已将数据源分配给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;
}
谁能告诉我我犯错了提前谢谢
【问题讨论】:
-
你是否也在 IB 中连接了代理和数据源
-
您在
numberOfSectionsInTableView和numberOfRowsInSection中返回什么值? -
CurrencyCell 是您的自定义单元格??
-
CurrencyCell *cell = (CurrencyCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
-
"yourArray" 可能为空,这就是为什么不调用 cellForRowAtIndexPath 方法
标签: iphone uitableview ios5 xcode4