NSInternalInconsistencyException',原因:'无效更新:无效的节数

时间:2014-01-16 11:19:06

标签: ios objective-c uitableview

我遇到了问题:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
float reload_distance = 15;
if(y > h + reload_distance)
{
    if(newNumberOfItemsToDisplay <= [self.arrPodsCanal count])
    {

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

        numberOfItemsToDisplay = newNumberOfItemsToDisplay;

        [self.myTable beginUpdates];

        [self.myTable insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationMiddle];
        if (numberOfItemsToDisplay == totalNumberOfItems)
                [self.myTable deleteSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationFade];

        [self.myTable endUpdates];
    }
}
}

在更新UITableView的最后一个块中,我收到此错误:

* 由于未捕获的异常'NSInternalInconsistencyException'而终止应用,原因:'尝试删除第1部分,但更新前只有1个部分'

问题是newNumberOfItemsToDisplay == [self.arrPodsCanal count]

1 个答案:

答案 0 :(得分:0)

改变:

[self.myTable deleteSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationFade];

要:

[self.myTable deleteSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationFade];