gpt4 book ai didi

uitableview - iOS UItableview scrollToRowAtIndexPath不再起作用

转载 作者:行者123 更新时间:2023-12-03 12:21:27 35 4
gpt4 key购买 nike

今天早上,我刚刚安装了包含iOS 6的新Xcode。

我有一个加载了包含章节和行的plist文件的表格 View 。各章定义各节。

用户选择章节和行,并将tableview自动滚动到正确的位置(在viewDidLoad中)。

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:linePos inSection:chapterPos];
[self.tableView scrollToRowAtIndexPath:indexPath
atScrollPosition:UITableViewScrollPositionTop animated:YES];

这在iOS5模拟器中效果很好。

在iOS 6模拟器中尝试此操作时,不会执行滚动。我没有错误。我已经检查过,linePos和ChapterPos接收正确的值,但是没有执行滚动。

有什么想法吗?

最佳答案

物镜

[self.tableView reloadData];
dispatch_async(dispatch_get_main_queue(), ^{
NSIndexPath *rowIndexPath = [NSIndexPath indexPathForRow:3 inSection:0];
[self.tableView scrollToRowAtIndexPath:rowIndexPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
});

迅速
tableView.reloadData()
DispatchQueue.main.async {
let indexPath = IndexPath(row: linePos, section: chapterPos)
self.tableView.scrollToRow(at: indexPath, at: .top, animated: true)
}

关于uitableview - iOS UItableview scrollToRowAtIndexPath不再起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12514770/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com