点击返回上一屏幕后,应用停止

时间:2015-05-22 10:06:11

标签: ios uitableview crash back

我用服务器中的数据填充tableview。我填写得很好,但是我有一个功能可以在另一个屏幕上显示每行的详细信息,但当我推回时,应用程序崩溃,但我不知道为什么!!

这是我的功能:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 1) {
    NSUInteger i, totalNumberOfItems = [gestiones count];
    NSUInteger newNumberOfItemsToDisplay = MIN(totalNumberOfItems, numberOfItemsToDisplay + kNumberOfItemsToAdd);
    NSMutableArray *indexPaths = [[NSMutableArray alloc] init];

    for (i=numberOfItemsToDisplay; i<newNumberOfItemsToDisplay; i++) {
        [indexPaths addObject:[NSIndexPath indexPathForRow:i inSection:0]];
    }

    numberOfItemsToDisplay = newNumberOfItemsToDisplay;

    [tableView beginUpdates];
    [tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationTop];
    if (numberOfItemsToDisplay == totalNumberOfItems) {
        [tableView deleteSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationTop];
    }
    [tableView endUpdates];

    // Scroll the cell to the top of the table

    NSIndexPath *scrollPointIndexPath;

    if (newNumberOfItemsToDisplay < totalNumberOfItems) {
        scrollPointIndexPath = indexPath;
    } else {
        scrollPointIndexPath = [NSIndexPath indexPathForRow:totalNumberOfItems-1 inSection:0];
    }

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 200000000), dispatch_get_main_queue(), ^(void){
        [tableView scrollToRowAtIndexPath:scrollPointIndexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
    });

    [tableView deselectRowAtIndexPath:indexPath animated:YES];

}else{
    Gestion *ges = [gestiones objectAtIndex:indexPath.row];
    DetalleGestionViewController *vcc = [[DetalleGestionViewController alloc] initWithNibName:@"DetalleGestionViewController" bundle:nil];
    vcc.gestion = ges;
    [self.navigationController pushViewController:vcc animated:YES];

    NUEVA_GESTION = YES;

    [gestiones removeAllObjects];
}

}

使用&#34; NUEVA_GESTION&#34;我准备应用程序重新加载表数据。

有人可以帮助我吗?

0 个答案:

没有答案