这是我创建单元格的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellIdentifier = @"cellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell)
{
cell = [[[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil] lastObject];
}
UIImageView * imageView = (UIImageView *)[cell viewWithTag:1];
imageView.image = [UIImage imageNamed:@"nature.jpg"];
UILabel *nameLabel = (UILabel *)[cell viewWithTag:2];
nameLabel.text = @"Some text";
UILabel *priceLabel = (UILabel*)[cell viewWithTag:3];
priceLabel.text = [_prices objectAtIndex:indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
我从笔尖创建它:
但是 iOS 7 和 iOS 6 之间存在差异,请看下面的截图: