您的位置:首页 > 移动开发 > IOS开发

iOS中点击顶部statusBar让tableView回到第一行

2016-02-03 18:19 549 查看
在iOS开发中 ,有一个非常基础的功能就是用户点击屏幕顶部状态栏的时候, tableView会自动会滚到第一行.

其实这个很简单 , 就是系统对的一个属性scrollToTop .系统默认的这个属性的值是YES.

// When the user taps the status bar, the scroll view beneath the touch which is closest to the status bar will be scrolled to top, but only if its `scrollsToTop` property is YES, its delegate does
not return NO from `shouldScrollViewScrollToTop`, and it is not already at the top.
// On iPhone, we execute this gesture only if there's one on-screen scroll view with `scrollsToTop` == YES. If more than one is found, none will be scrolled.
@property(nonatomic)BOOL  scrollsToTop
__TVOS_PROHIBITED;         // default is YES.
其实官方文档已经写的很清楚了,注意  当一个控制器里有超过一个以上可以滚动的视图的时候,这个属性就不会起作用了,那如何解决呢?

其实很简单,就是禁用掉其他的你不需要让他回到顶端的滚动视图的这个属性 举例如下

 //点击顶部statusBar让tableView回到第一行
    self.tableList.scrollsToTop =YES;
    self.menview.tableview.scrollsToTop
= NO;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: