如果canFocusRowAtIndexPath设置为NO,tableView的内容偏移会自动更改

时间:2017-04-12 16:30:08

标签: objective-c uitableview tvos

问题:再次滚动到tableView会更改内容偏移量,它会隐藏第一个tableView单元格。

我知道有很多关于滚动问题的帖子有tableView的scrollView,其中tableView内容在滚动后偏移了变化,但解决方案并没有帮助我。

我尝试在 - (void)layoutSubviews方法中将内容偏移设置为0,但没有帮助。此外,这没有任何帮助。

self.automaticallyAdjustsScrollViewInsets = NO;
self.parentViewController.automaticallyAdjustsScrollViewInsets = NO;

详细信息: 当tableView加载时,我看到内容偏移设置为{0,0}

打印$ 6的说明:

<UITableView: 0x7fca15828400; frame = (0 0; 1920 1080); autoresize = RM+BM; gestureRecognizers = <NSArray: 0x60800024cb40>; layer = <CALayer: 0x60800022c780>; contentOffset: {0, 0}; contentSize: {1920, 1600}>

当我向下滚动,再向上滚动时,我看到胶印内容发生了变化。

打印10美元的描述:

<UITableView: 0x7fca14880400; frame = (0 0; 1920 1080); autoresize = RM+BM; gestureRecognizers = <NSArray: 0x618000056da0>; layer = <CALayer: 0x618000037920>; contentOffset: {0, 108}; contentSize: {1920, 3754}>

但是,我将canFocusRowAtIndexPath设置为YES,我没有看到scrollView的问题,但我不希望tableViewCell聚焦。

        - (BOOL)tableView:(UITableView *)tableView canFocusRowAtIndexPath:(NSIndexPath *)indexPath {
            return YES;
        }

请帮忙吗?

1 个答案:

答案 0 :(得分:0)

这个问题是因为UICollectionViewFlowLayout是我每次调用tableView的cellForRowIndexpath时以编程方式设置并弄乱内容偏移量。