89.UIScrollView的一些不常用属性
来源:互联网 发布:淘宝买韩国专辑靠谱吗 编辑:程序博客网 时间:2024/05/30 05:24
今天来说关于UIScrollView的一些属性, 虽然不是特别常用但是有时候会有大作用的几个属性.
UIScrollView交互之键盘收回(keyboardDismissMode)
有些关于键盘收回的事件处理会写在UIScrollview的代理方法中,将要开始拖拽其时触发: -(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
其实更简单的方法是通过设置UIScrollview的属性在其滑动时自动回收
scrollview.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
下面就来看看这个属性.
UIScrollView *scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 375, 667)]; scrollView.backgroundColor = [UIColor lightGrayColor]; scrollView.contentSize = CGSizeMake(375, 3000); [self.view addSubview:scrollView]; UITextField *tf = [[UITextField alloc]initWithFrame:CGRectMake(0, 200, 100, 100)]; tf.backgroundColor = [UIColor greenColor]; [scrollView addSubview:tf]; // UIScrollViewKeyboardDismissMode 枚举 scrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
关于UIScrollViewKeyboardDismissMode枚举值:
UIScrollViewKeyboardDismissModeNone,
UIScrollViewKeyboardDismissModeOnDrag, // dismisses the keyboard when a drag begins
UIScrollViewKeyboardDismissModeInteractive, // the keyboard follows the dragging touch off screen, and may be pulled upward again to cancel the dismiss
第一个是默认值, None.
第二个, 当 UIScrollview 开始拖拽时, 便会收回键盘. 一般这个用的比较多
第三个, 当UIScrollview 拉至顶端后再次下拉, 便会收回键盘. 这个时机就类似于下拉刷新的操作时机.
UIScrollView事件传递(delaysContentTouches/cancelsContentTouches)
首先分析下当你的手指touch一个 UIScrollview开始,scrollView开始一个timer,如果:
1.150ms内如果你的手指没有任何动作,消息就会传给subView。
2.150ms内手指有明显的滑动(一个swipe动作),scrollView就会滚动,消息不会传给subView。
3.150ms内手指没有滑动,scrollView将消息传给subView,但是之后手指开始滑动,scrollView传送touchesCancelled消息给subView,然后开始滚动。
delaysContentTouches
@property(nonatomic) BOOL delaysContentTouches; // default is YES. if NO, we immediately call -touchesShouldBegin:withEvent:inContentView:. this has no effect on presses
默认是YES,使用上面的150ms的timer,如果设置为NO,touch事件立即传递给subView,不会有150ms的等待。
cancelsContentTouches
@property(nonatomic) BOOL canCancelContentTouches; // default is YES. if NO, then once we start tracking, we don’t try to drag if the touch moves. this has no effect on presses
默认为YES,如果设置为NO,这消息一旦传递给subView,这scroll事件不会再发生。
- 89.UIScrollView的一些不常用属性
- UIScrollView的一些属性
- UIScrollView 的常用属性
- UIScrollView的常用属性
- UIScrollView的常用属性
- UIScrollView的简单使用 以及一些常用属性
- UIScrollView & UITableView 一些常用方法与属性
- UIScrollView 常用的一些方法
- UIScrollView 常用的一些方法
- UIScrollView的常用属性和方法
- ios UIScrollView 一些属性
- UIScrollView常用属性
- Table的一些不常用的属性(ZZ)
- jQuery中一些不常用的方法属性
- css里一些我们不常用的属性
- 一些不常用的html标签及css属性
- CSS一些不常用但是有用的属性
- UILabel的一些不常用属性,持续更新
- 一个经典问题 (LCS)
- Android Gradle Plugin中 ApplicationVariant文件内的可用属性
- 启动apk的常用方法
- HttpStatus返回状态码
- 遍历Map的4种方法
- 89.UIScrollView的一些不常用属性
- JSON基础以及JSON字符串转换为JSON对象
- Group by与having理解
- Android官方数据绑定框架DataBinding
- 68、 createSQLQuery与createQuery的区别
- 264. Ugly Number II
- GEEK编程练习— —两个已序数组的中值
- Apache与Nginx的优缺点比较
- README.txt