Kam*_*ash 5 uitableview ios swift
我正在尝试计算tableView的内容大小高度,它具有动态增加的单元格.为此,我正在编写代码 -
override func viewDidLoad()
{
super.viewDidLoad()
self.tableView.estimatedRowHeight = 150
self.tableView.rowHeight = UITableViewAutomaticDimension
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCellWithIdentifier("cell1", forIndexPath: indexPath) as! MostLikedTVCscnd
cell.image.image = imageArr[indexPath.row] as? UIImage
cell.aboutLbl.text = labelArr[indexPath.row] as? String
let contentSizeHeight = tableView.contentSize.height//But here I am not getting the proper height
return cell
}
Run Code Online (Sandbox Code Playgroud)
我检查的问题的答案计算的tableView内容大小- /sf/answers/1255795691/ 读取
注意那些对他们来说,这是行不通的 - 的tableView:与contentSize estimatedHeightForRowAtIndexPath混乱,所以你可能有运气只是通过删除您的IT实施. - weienw
那么,尽管有动态单元格大小,我还能获得正确的内容大小吗?
您可以使用键值观察 (KVO),以便在表视图\xe2\x80\x99s 内容大小发生变化时收到通知。这可能适用于您尝试执行的操作,也可能不适用于您\xe2\x80\x99。我\xe2\x80\x99m只是不清楚你\xe2\x80\x99想要获得什么,但我不\xe2\x80\x99t认为尝试在cellForRowAtIndexPath中使用它会很好。
\n 归档时间: |
|
查看次数: |
1111 次 |
最近记录: |