当前位置:首页 > 操作系统 > Ios

iOS事件(触摸,移动,晃动)

             1
            //
            开始触摸
             2 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 3{
 4     NSLog(@"你触摸了屏幕");
 5}
 6//移动 7 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 8{
 9     NSLog(@"手指移动");
10}
11//触摸结束12 - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event13{
14     NSLog(@"触摸结束");
15}
16//中断触摸17 - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event18{
19     NSLog(@"中断触摸");
20}
21//开始摇晃手机22 - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event23{
24     NSLog(@"开始摇晃");
25}
26//摇晃被中断27 - (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event28{
29     NSLog(@"中断摇晃");
30}
31//摇晃结束32 - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event33{
34     NSLog(@"摇晃结束");
35 }

新建一个Controller,可以通过添加以上的基本的方法来响应基本的一些事件。

原文:http://www.cnblogs.com/bishuai/p/5207523.html


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!