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;
其实这个很简单 , 就是系统对的一个属性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;
相关文章推荐
- iOS开发之字符串显示不同的颜色
- iOS 循环语句的使用
- ios web 跳转
- iOS 9 学习系列:Contacts Framework
- iOS layer 的粒子视图和过度视图详解
- iOS Animation CATransaction事务 详解
- iOS开发之多线程GCD
- iOS:交换Button中图片与文字的左右位置
- How to use cocoa pod in your iOS project
- iOS开发之多线程技术
- iOS ----调用系统摄像捕捉人脸
- iOS中 最新支付宝支付(AliPay) 韩俊强的博客
- iOS中 最新支付宝支付(AliPay) 韩俊强的博客
- ios 类似安卓提示框自动消失
- iOS开发 主线程问题
- iOS开发——手机号,密码,邮箱,身份证号,中文判断
- 解决sitescope不能用Netbios连接remote windows server
- IOS 手势事件的冲突
- 如何提高自己的iOS开发水平(转自唐巧的博客)
- iOS开发日记59-推荐两本好书