[英]iOS11 UITableview reloadRowsAtIndexPaths glitch
任何人都可以幫助我理解或解決iOS11中的這個UITableView故障。 我設法在一個相當簡單的測試用例中重現了我的問題。
https://github.com/trapper-/iOS11-tableview-glitch
當重新加載靠近tableview底部的單元格時,重新加載的單元格將開始奇怪地滾動,其他單元格開始移動並跳轉。
重新加載多個單元格時會變得更糟,但我不想讓這個簡單的例子復雜化。
這應該有所幫助:
[UIView performWithoutAnimation:^{
[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}];
如果我像這樣使用它的工作。
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 100;
}
嘗試在viewDidLoad上向表視圖提供estimatedRowHeight為0 。 這個對我有用。
請嘗試設置你的表視圖estimatedRowHeight(在viewDidLoad方法中): self.tableView.estimatedRowHeight = 100;
默認情況下tableView.rowHeight設置為UITableViewAutomaticDimension,但您需要設置estimatedRowHeight From apple - “要啟用自調整表格視圖單元格,您必須將表格視圖的rowHeight屬性設置為UITableViewAutomaticDimension。您還必須為estimatedRowHeight指定值一旦設置了這兩個屬性,系統就會使用自動布局來計算行的實際高度。“
您可以查看: https : //developer.apple.com/library/content/documentation/UserExperience/Conceptual/AutolayoutPG/WorkingwithSelf-SizingTableViewCells.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.