【发布时间】:2014-03-19 06:36:41
【问题描述】:
我已按升序对数组进行了排序。我需要显示要着色的表格的第一个值。我该怎么做呢
我的代码是:
NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"isDefault" ascending:NO];
sortedArray = [beneficiariesArray sortedArrayUsingDescriptors:[NSArray arrayWithObject:descriptor]];
NSLog(@"This is Sorted Array %@",sortedArray);
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
static NSString *simpleTableIdentifier = @"SimpleTableItem";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
cell.textLabel.text = [[sortedArray objectAtIndex:indexPath.row] objectForKey:@"Fullname"];
return cell;
}
【问题讨论】:
标签: ios iphone objective-c uitableview