iOS 显示表中数组的数据,最后一个索引除外

标签 ios uitableview nsarray directions

我已经在一个数组的 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;
}

最佳答案

试试这个

将 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:

关于iOS 显示表中数组的数据,最后一个索引除外,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15193707/

相关文章:

objective-c - 查找与特定字符串匹配的 NSString NSArray 的索引?

ios - 在 iOS 7 中,通话摘要应用程序未返回前台

objective-c - Sudzc响应出现问题(iOS ARC)

ios - UITableview 的触摸事件

ios - indexpath.row 从 1 而不是 0 开始

ios - 如何从字典格式的 NSArray 中提取对象

iphone - 如何以编程方式确定 iPhone 上的默认铃声?

ios - 在用户交互发生之前,PFQueryTableViewController 不应该加载任何对象?

ios - UITableViewCell 自动高度不正确,直到我滚动

ios - 有没有办法复制数组中 NSDictionaries 的数量?