(ios) 屏幕触摸总结

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

(ios) 屏幕触摸总结
  [self becomeFirstResponder];
     //允许多点互动
     self.view.multipleTouchEnabled=TRUE;
(ios) 屏幕触摸总结

实现事件部分

(ios) 屏幕触摸总结
#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
{


}
(ios) 屏幕触摸总结

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

(ios) 屏幕触摸总结
UITapGestureRecognizer *tapGestureTel = [[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(teleButtonEvent:)]autorelease];

[telephoneLabel addGestureRecognizer:tapGestureTel];
(ios) 屏幕触摸总结

 

3 屏幕晃动实现

(ios) 屏幕触摸总结
//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)
{

} 
(ios) 屏幕触摸总结

(ios) 屏幕触摸总结

上一篇:poj Spell checker


下一篇:宿主环境(host environment)