0

配列からテーブルビューにデータを表示しましたが、配列の最後のオブジェクトを表示したくありません。どうすればこれを達成できますか? ありがとう

- (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;
}
4

2 に答える 2

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:
于 2013-03-04T06:10:42.460 に答える
1

これを使ってみてください... これでうまくいくと思います。

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if([[route maneuvers] count] == 0)
        return 0;
    else
       return [[route maneuvers] count] - 1;
}
于 2013-03-04T06:03:46.040 に答える