IOS Dev Intro - UIControlEvent
来源:互联网 发布:上海财经大学知乎 编辑:程序博客网 时间:2024/04/29 12:41
在控件事件中,简单解释下下面几个事件。
说明:由于是在“iOS 模拟器”中测试的,所以不能用手指,只能用鼠标。
1)UIControlEventTouchDown
指鼠标左键按下(注:只是“按下”)的动作
2)UIControlEventTouchDownRepeat
指鼠标左键连续多次重复按下(注:只是“按下”)的动作,比如,鼠标连续双击、三击、……、多次连击。
说明:多次重复按下时,事件序列是这样的:
UIControlEventTouchDown ->
(UIControlEventTouchUpInside) ->
UIControlEventTouchDown ->
UIControlEventTouchDownRepeat ->
(UIControlEventTouchUpInside) ->
UIControlEventTouchDown ->
UIControlEventTouchDownRepeat ->
(UIControlEventTouchUpInside) ->
...
除了第一次按下外,后面每次摁下都是一个UIControlEventTouchDown事件,然后紧跟一个UIControlEventTouchDownRepeat事件。
3)UIControlEventTouchDragInside
指按下鼠标,然后在控件边界范围内拖动。
4)UIControlEventTouchDragOutside
与UIControlEventTouchDragInside不同的是,拖动时,鼠标位于控件边界范围之外。但首先得有个UIControlEventTouchDown事件,然后接一个UIControlEventTouchDragInside事件,再接一个UIControlEventTouchDragExit事件,这时,鼠标已经位于控件外了,继续拖动就是UIControlEventTouchDragOutside事件了。
具体操作是:在控件里面按下鼠标,然后拖动到控件之外。
5)UIControlEventTouchDragEnter
指拖动动作中,从控件边界外到内时产生的事件。
6)UIControlEventTouchDragExit
指拖动动作中,从控件边界内到外时产生的事件。
7)UIControlEventTouchUpInside
指鼠标在控件范围内抬起,前提先得按下,即UIControlEventTouchDown或UIControlEventTouchDownRepeat事件。
8)UIControlEventTouchUpOutside
指鼠标在控件边界范围外抬起,前提先得按下,然后拖动到控件外,即 UIControlEventTouchDown -> UIControlEventTouchDragInside(n 个) -> UIControlEventTouchDragExit -> UIControlEventTouchDragOutside(n 个) 时间序列,再然后就是抬起鼠标,产生UIControlEventTouchUpOutside事件。
================================================================================================
uibutton 的随手指移动 UIControlEventTouchUpInside
[view_button addTarget:self action:@selector(dragBegan:withEvent: )
forControlEvents: UIControlEventTouchDown];
[view_button addTarget:self action:@selector(dragMoving:withEvent: )
forControlEvents: UIControlEventTouchDragInside];
[view_button addTarget:self action:@selector(dragEnded:withEvent: )
forControlEvents: UIControlEventTouchUpInside |
UIControlEventTouchUpOutside];
2、写用到的三个方法函数
- (void) dragBegan: (UIControl *) c withEvent:ev
{
NSLog(@"Button moving bagin ......");
}
- (void) dragMoving: (UIControl *) c withEvent:ev
{
NSLog(@"Button is moving ..............");
UIButton *bt = (UIButton *)c;
c.center = [[[ev allTouches] anyObject] locationInView:self.view];
}
- (void) dragEnded: (UIControl *) c withEvent:ev
{
NSLog(@"Button moving end..............");
UIButton *bt = (UIButton *)c;
c.center = [[[ev allTouches] anyObject] locationInView:self.view];
}
3、ok 完成 体验一下吧。
- IOS Dev Intro - UIControlEvent
- IOS Dev Intro - UIButton
- IOS Dev Intro - UILabel
- IOS Dev Intro - String
- IOS Dev Intro - FBO
- IOS Dev Intro - NSDictionary
- IOS Dev Intro - NSArray
- IOS Dev Intro - NSInteger
- IOS Dev Intro - NSString
- IOS Dev Intro - UISwitch
- IOS Dev Intro - Sandbox
- IOS Dev Intro - NSFileManager
- IOS Dev Intro - NSBundle
- IOS Dev Intro - NSSet
- IOS Dev Intro - Property
- IOS Dev Intro - Block
- IOS Dev Intro - Category
- IOS Dev Intro - NSCondtion
- 命令模式(Command Pattern)
- openwrt时间设置查看
- ESAPI学习笔记
- Windows服务 开机自动运行
- 剑指offer-001
- IOS Dev Intro - UIControlEvent
- 向量中断和非向量中断
- EhLib 7.0.133,有关DbGridEh的使用的一些细节
- Elasticsearch集群搭建实战
- UITableView学习笔记
- 第二天 关于XML语言
- 剑指offer-面试题12:打印1到最大的n位数
- Install SharePoint2016 RTM - Hardware and Software Requirements
- Go语言概览——《Java程序员学习Go》之一