【发布时间】:2015-09-09 05:12:31
【问题描述】:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:@"myCell"];
if (cell == nil)
{
[tableView registerNib:[UINib nibWithNibName:@"CustomCell" bundle:nil] forCellReuseIdentifier:@"myCell"];
cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:@"myCell"];
}
if (cell.tag == 0)
{
}
str = [jsonData objectAtIndex:cell.tag];
NSDictionary *dict = [jsonData objectAtIndex:indexPath.row];
cell.lblDeliveryTime.text = [dict valueForKey:@"sysord_ExpectedDeliveryTime"];
cell.lblOrderPlacedTime.text = [dict valueForKey:@"sysord_OrderDateTime"];
cell.lblDeliveryPickUP.text = [dict valueForKey:@"sysord_DeliveryType"];
NSDictionary *dict1 = [jsonData objectAtIndex:cell.tag];
orderidString = [dict1 valueForKey:@"sysord_ID"];
DetailViewController *detailVC=[[DetailViewController alloc]initWithNibName:@"DetailViewController" bundle:nil];
return cell;
}
【问题讨论】:
-
哪一行给出了错误? (提示:使用调试器逐步找出答案。)
-
究竟是哪一行?我猜这是三个“cell.ZzZ.text”或
orderidString之一。dict(或dict1)中的值是NSNumber,您可以像使用NSString一样使用它。 -
您尚未将标签设置为单元格,并尝试访问基于 cell.tag 的值。不起作用。您还将 [jsonData objectAtIndex:cell.tag] 分配给 str 和 dict1。它不清楚。这里发生了什么。但是 [jsonData objectAtIndex:indexPath.row] 是有意义的,因为 indexpath 会自动生成。
标签: objective-c uitableview xib