首页 > 其他 > 详细

(ios) 屏幕触摸总结

时间:2014-01-16 21:48:27      阅读:382      评论:0      收藏:0      [点我收藏+]

1  屏幕触控实现(单击 双击)

bubuko.com,布布扣
  [self becomeFirstResponder];
     //允许多点互动
     self.view.multipleTouchEnabled=TRUE;
bubuko.com,布布扣

实现事件部分

bubuko.com,布布扣
#pragma mark-
#pragma mark touch 

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{

     //触摸开始
   
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{

    //移动
    
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
  //结束
 UITouch *atouch=[touches anyObject];
    if(atouch.tapCount>=2)
    {
        //双击
    }
    else if(atouch.tapCount==1)
    {
    
       //单击
    }
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{


}
bubuko.com,布布扣

2 手势识别(UIlabel 点击事件实现)

bubuko.com,布布扣
UITapGestureRecognizer *tapGestureTel = [[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(teleButtonEvent:)]autorelease];

[telephoneLabel addGestureRecognizer:tapGestureTel];
bubuko.com,布布扣

 

3 屏幕晃动实现

bubuko.com,布布扣
//AppDelegate 中实现
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    application.applicationSupportsShakeToEdit = YES;
}

//或者代码中实现
 [[UIApplication sharedApplication] setApplicationSupportsShakeToEdit:YES];

//ViewController 中实现下面方法

- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event NS_AVAILABLE_IOS(3_0);
{

}
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event NS_AVAILABLE_IOS(3_0)
{
    if (event.subtype == UIEventSubtypeMotionShake) {
        
        //摇一摇 行为
         
    }
}
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event NS_AVAILABLE_IOS(3_0)
{

} 
bubuko.com,布布扣

(ios) 屏幕触摸总结

原文:http://www.cnblogs.com/macroxu-1982/p/3521396.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!