[英]How to use estimatedHeightForRowAtIndexPath with async func? swift
I'm moving and app I had on Parse to Firebase and I ran into an issue with a cell that needs to get resized.It contains a textview that recieves data, since the text varies in size, I am using this two methods: 我正在移动并将解析到Firebase上的应用程序遇到一个需要调整大小的单元格的问题,它包含一个可以接收数据的textview,因为文本的大小各不相同,因此我正在使用以下两种方法:
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
override func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
With Parse this worked perfectly because I would recieve the entire object that I had to pass to the DetailTableView in the MainTableView. 使用Parse可以完美地工作,因为我会收到必须传递给MainTableView中的DetailTableView的整个对象。 With Firebase, I handle it differently, I retrieve what the MainTableView needs, then I just pass a reference to the DetailTableView and again retrieve whatever I need there.
使用Firebase,我将以不同的方式进行处理,检索MainTableView所需的内容,然后将引用传递给DetailTableView,然后再次检索在那里需要的内容。 The problem seems to be that the size of the cell gets set before the async function can set the text.
问题似乎是在异步功能可以设置文本之前设置了单元格的大小。 Any ideas on how to solve this?
关于如何解决这个问题的任何想法?
Thanks in advance! 提前致谢!
我认为您可以通过调用tableView.beginUpdates()
tableView.endUpdates()
来包装在单元格上设置文本的代码
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.