当前位置:编程学习 > wap >>

iPhone 手势识别

 

- (void)viewDidLoad { 

    [super viewDidLoad]; 

 

    UISwipeGestureRecognizer *recognizer = nil; 

    // 

    // 向右划动 

    // 

    recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)]; 

    [recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)]; 

    [self.view addGestureRecognizer:recognizer]; 

    [recognizer release]; 

 

    // 

    // 向左划动 www.zzzyk.com

    // 

    recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)]; 

    [recognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)]; 

    [self.view addGestureRecognizer:recognizer]; 

    [recognizer release]; 

 

- (void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer {  

    if (recognizer.direction == UISwipeGestureRecognizerDirectionRight) { 

        // TODO: 

    } 

    else if (recognizer.direction == UISwipeGestureRecognizerDirectionLeft) { 

        // TODO: 

    } 

 

摘自 wangsoko的专栏

补充:移动开发 , IOS ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,