iOS 8 Auto cell height - Can't scroll to last row

前端 未结 12 1200
慢半拍i
慢半拍i 2020-11-28 20:50

I am using iOS 8 new self-sizing cells. Visually it works good - each cell gets its right size. However, if I try to scroll to the last row, the table view

12条回答
  •  感情败类
    2020-11-28 21:29

    This has been a very annoying bug, but I think I found a permanent solution, though I cannot fully explain why.

    Call the function after a tiny (unnoticed) delay:

    let delay = 0.1 * Double(NSEC_PER_SEC)
    let time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay))
    
    dispatch_after(time, dispatch_get_main_queue(), {
      tableView.scrollToRowAtIndexPath(NSIndexPath(forRow: model.dataArray.count - 1, inSection: 0), atScrollPosition: .Bottom, animated: true)
    })
    

    Do tell me if this works for you as well.

提交回复
热议问题