你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> iPhone 手勢識別

iPhone 手勢識別

編輯:IOS開發綜合

 

- (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.2cto.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的專欄

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved