最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

[基本解决]Swift在TableView添加section和row行然后滚动

Swift crifan 2962浏览 0评论

想要实现,在append了对应的item后,再去滚动:

            gContactViewController?.contactTableView.beginUpdates()
           
let itemIndexPath:NSIndexPath = NSIndexPath(forRow: indexInSection, inSection: sectionIdx)
           
print("itemIndexPath=\(itemIndexPath)")
           
           
//check is append or insert
            gContactViewController?.contactTableView.insertRowsAtIndexPaths(
                [itemIndexPath],
                withRowAnimation:
UITableViewRowAnimation.Automatic)
           
gContactViewController?.contactTableView.endUpdates()
            gContactViewController?.contactTableView.scrollToRowAtIndexPath(itemIndexPath, atScrollPosition: UITableViewScrollPosition.Middle, animated: true)

但是运行失败。

swift tableview append section scroll

 Programmatic UITableView Scrolling – Grok Swift

ios – How do i automatically scroll in a table view? Using swift – Stack Overflow

swift tableview append section

ios – Adding sections, separated by dates, to UITableView in Swift – Stack Overflow

Add Rows to Table View Tutorial in iOS8 with Swift – iOScreator

swift tableview append row

Inserting and Deleting Rows and Sections

insertRowsAtIndexPaths(_:withRowAnimation:) – UITableView Class Reference

[基本搞懂]swift中UITableView中如何只刷新某个section的某个单独的行

[已解决]swift中已更新对应行的数据源但tableView的reloadRowsAtIndexPaths却还是出错崩溃:attempt to delete row 0 from section 0 which only contains 0 rows before the update

转载请注明:在路上 » [基本解决]Swift在TableView添加section和row行然后滚动

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
84 queries in 0.167 seconds, using 22.19MB memory