作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
通过调用 iOS 11.2 更新新的 XCODE 9.2 后出现奇怪的问题
let indexPath = IndexPath(item: 0, section: 1)
self.tableViewHome.reloadRows(at: [indexPath], with: .none)
这会导致整个 TableView 不必要的抖动,之前这些代码都很好。
iOS 11.2 的 GIF 图片
iOS 11.1 的 GIF 图片
如何停止这种抽搐,我必须在两个单元格之间重新加载表格 View 中的一个单元格。
我们将不胜感激。
谢谢
最佳答案
我的理解是,如果您真的想使用自动调整单元格大小(并且所有单元格的大小都不同),那么上述解决方案不适用于 iOS 11.2,所以我尝试的方法如下:
声明变量来存储单元格的高度
var cellHeightDictionary: NSMutableDictionary // To overcome the issue of iOS11.2
在viewDidLoad中初始化,
override func viewDidLoad() {
super.viewDidLoad()
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 125
cellHeightDictionary = NSMutableDictionary()
}
并像下面这样使用:
override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
cellHeightDictionary.setObject(cell.frame.size.height, forKey: indexPath as NSCopying)
}
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
if cellHeightDictionary.object(forKey: indexPath) != nil {
let height = cellHeightDictionary.object(forKey: indexPath) as! CGFloat
return height
}
return UITableViewAutomaticDimension
}
这对我有用,希望对你也有帮助
关于ios - UITableView 重新加载行在 iOS 11.2 中不自然地抽动 TableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47690381/
我有一列(VARCHAR 类型),其值如下: 1 2 3 1.1 1.1.1 1.2.1 5 4 7 8 9 10 10.2 10.1 我希望[e 选择此列并对其进行自然排序,如下所示: 1 1.1
我是一名优秀的程序员,十分优秀!