0

我必须正确获取 UITableView 上的核心数据值,但我没有在 UILabel 上获取核心数据值。

(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
  static NSString *CellId = @"Cell";

  Cell *cell=[table dequeueReusableCellWithIdentifier:CellId];
  if (cell==nil) {
      [[NSBundle mainBundle]loadNibNamed:@"Cell" owner:self options:nil];
      cell=self.custom;
  }
  // Get the event corresponding to the current index path and configure the table view cell.
  Student *stu = (Student *)[dataarr objectAtIndex:indexPath.row];
  cell.item.text = [stu name];
  cell.rate.text = [stu rate];
  currentindex=indexPath.row;
  return cell;
}
4

1 回答 1

0
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{


    static NSString *simpletableidentifier=@"simpletablecell";

    simpletablecell *cell=(simpletablecell *)[tableView dequeueReusableCellWithIdentifier:simpletableidentifier];

    if(cell==nil)
    {
        NSArray *nib=[[NSBundle mainBundle] loadNibNamed:@"simpletablecell" owner:self options:nil];
        cell=[nib objectAtIndex:0];
    }

    cell.cname.text=[[tabledata objectAtIndex:indexPath.row] objectForKey:@"CustomerName"];



    NSString *ocount=[NSString stringWithFormat:@"(OrderCount : %@)",[[tabledata objectAtIndex:indexPath.row] objectForKey:@"OrderCount"]];

    cell.ordercount.text=ocount;

    NSString *oid=[NSString stringWithFormat:@"%@",[[tabledata objectAtIndex:indexPath.row] objectForKey:@"CustomerId"]];

    cell.orderid.text=oid;
    cell.orderid.hidden=true;


    return cell;
}

在这里试试这个简单的表格单元格是自定义单元格。不要忘记设置它的标识符并为此创建 .h 和 .m 文件。

于 2013-01-24T12:32:30.260 回答