【问题标题】:When reloading UITableView make it so it doesn't scrolls to thew top重新加载 TableView 时使其不会滚动到顶部
【发布时间】:2011-05-28 01:08:58
【问题描述】:

我有一个 UITableView 填充了 Twitter 时间线。我也有滚动刷新(如 Tweetie/Twitter),当用户滚动刷新时,新内容会添加到顶部。我将如何做表格视图将内容添加到实际位置的顶部。换句话说,我不想在重新加载时首先显示最新的推文,而是应该将新内容添加到实际位置的顶部,必须滚动到顶部才能看到最新的推文。希望你们已经理解它,因为它可能有点难以理解;)

【问题讨论】:

  • 只是为了确保我理解正确,您想刷新页面以使当前视图成为 tableView 的新来源?换句话说,您想让 tableView 在刷新时向您显示最新的更新,而不必一直滚动到顶部?
  • 所以不是将内容添加到顶部,而是要将其添加到用户现在所在的位置?
  • 回答标题中的问题:使用 insertRowsAtIndexPaths:withRowAnimation:
  • 我想要的是,如果用户在顶部,当他/她通过拉动刷新重新加载时,内容被添加到顶部,但表格没有移动,它站在最新推文在刷新之前,必须向上滚动以查看新推文:)
  • 你可以看看 UITableView 类的引用,你会发现 – scrollToRowAtIndexPath:atScrollPosition:animated: – scrollToNearestSelectedRowAtScrollPosition:animated:

标签: iphone cocoa-touch ios


【解决方案1】:

感谢@TheBlack,这对我有帮助:)

报价>

You could have taken a peek into UITableView class reference and you'd find – 
scrollToRowAtIndexPath:atScrollPosition:animated: – 
scrollToNearestSelectedRowAtScrollPosition:animated

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-03
    • 1970-01-01
    • 2015-03-19
    • 2021-09-18
    • 2023-03-05
    • 1970-01-01
    • 2020-05-25
    • 1970-01-01
    相关资源
    最近更新 更多