我在数组的tableview中显示了我的数据,但我不想显示数组中的最后一个对象。我该如何做到这一点?感谢
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
MQManeuver *manuever = [[route maneuvers] objectAtIndex:indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
cell.imageView.image = nil;
cell.detailTextLabel.numberOfLines = 2;
cell.detailTextLabel.adjustsFontSizeToFitWidth = YES;
cell.detailTextLabel.text = manuever.narrative;
cell.detailTextLabel.font = [UIFont boldSystemFontOfSize:12];
cell.detailTextLabel.textColor = [UIColor blackColor];
float distance = manuever.distance;
NSString *distance1 = [NSString stringWithFormat:@"%.1f", distance];
cell.textLabel.text = [distance1 stringByAppendingFormat:@" miles"];
cell.textLabel.textColor = [UIColor grayColor];
return cell;
}
答案 0 :(得分:1)
请尝试使用此...我认为这样可以正常使用。
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if([[route maneuvers] count] == 0)
return 0;
else
return [[route maneuvers] count] - 1;
}
答案 1 :(得分:1)
试试这个
将NSArray数据转移到NSMutableArray
NSMutableArray Methods for Removing Objects:
– removeAllObjects
– removeLastObject ///you can use removeLastObject Method
– removeObject:
– removeObject:inRange:
– removeObjectAtIndex:
– removeObjectsAtIndexes:
– removeObjectIdenticalTo:
– removeObjectIdenticalTo:inRange:
– removeObjectsFromIndices:numIndices:
– removeObjectsInArray:
– removeObjectsInRange: