Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Xcode-[UITableView\u contentOffsetForScrollingToRowatineXPath:atScrollPosition:]:第(7)行超出第(0)节的界限(0)。&x27;_Ios_Objective C_Xcode_Uiscrollview_Uicollectionview - Fatal编程技术网

Ios Xcode-[UITableView\u contentOffsetForScrollingToRowatineXPath:atScrollPosition:]:第(7)行超出第(0)节的界限(0)。&x27;

Ios Xcode-[UITableView\u contentOffsetForScrollingToRowatineXPath:atScrollPosition:]:第(7)行超出第(0)节的界限(0)。&x27;,ios,objective-c,xcode,uiscrollview,uicollectionview,Ios,Objective C,Xcode,Uiscrollview,Uicollectionview,我刚刚在我的Xcode项目中实现了AGPhotoBrowser类,我得到了以下错误: Terminating app due to uncaught exception 'NSRangeException', reason: '-[UITableView _contentOffsetForScrollingToRowAtIndexPath:atScrollPosition:]: row (7) beyond bounds (0) for section (0).' 发生崩溃的代码如下所示: #

我刚刚在我的Xcode项目中实现了
AGPhotoBrowser
类,我得到了以下错误:

Terminating app due to uncaught exception 'NSRangeException', reason: '-[UITableView _contentOffsetForScrollingToRowAtIndexPath:atScrollPosition:]: row (7) beyond bounds (0) for section (0).'
发生崩溃的代码如下所示:

#pragma mark - UIScrollViewDelegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if (!self.currentWindow.hidden && !_changingOrientation) {
        [self.overlayView resetOverlayView];

        CGPoint targetContentOffset = scrollView.contentOffset;

        UITableView *tv = (UITableView*)scrollView;
        NSIndexPath *indexPathOfTopRowAfterScrolling = [tv indexPathForRowAtPoint:targetContentOffset];

        [self setupPhotoForIndex:indexPathOfTopRowAfterScrolling.row];
    }
}

当我退出执行此操作的
ViewController
时,崩溃似乎就发生了

错误告诉您,您的表在索引7处没有任何行。这意味着表视图由7行组成,indexath.row的最大范围可以是6(因为UITableView的行索引从0开始)。无论何时在索引路径调用超出表范围的行,它都会抛出一个错误

当我忽略设置tableview的委托和数据源时,我收到了这个错误;因此,似乎
nil
也是“出界”的


Xcode:6.4,iOS:8.x

在调用
ScrollToRowatinexPath()
之前重新加载
TableView
数据


我设法修好了-谢谢你!这是因为我使用的datasource委托正在从NSMutableArray提取tableview中的项目数,所以我这样做了:-(void)viewWillEnglish:(BOOL)animated{assets=nil;ag=nil;}:)
[contentTableView reloadData];