你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS編程技術 >> iOS開發UI高級手勢識別器

iOS開發UI高級手勢識別器

編輯:IOS編程技術

####手勢識別器
UIGestureRecognizer類

·UITapGestureRecognizer(輕擊)

·UIPinchGestureRecognizer(捏合)

·UIPanGestureRecognizer(平移) 事實調用

·UISwipeGestureRecognizer(輕掃)

·UIRotationGestureRecognizer(旋轉)

·UILongPressGestureRecognizer(長按)

alloc initwithTar
[singleTap requireGestureRecognizerToFail:doubleTap];

####具體實現
//1 單擊
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction:)];
[imageV addGestureRecognizer:tap];

//2 雙擊
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction1:)];
//點擊的次數
doubleTap.numberOfTapsRequired = 2;
[imageV addGestureRecognizer:doubleTap];

//雙擊失敗是單擊 ---->雙擊成功,單擊不算
[tap requireGestureRecognizerToFail:doubleTap];

//3 長按
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longPressAction:)];
[imageV addGestureRecognizer:longPress];


//4 輕掃
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeAction:)];
//屬性:輕掃方向
swipe.direction = UISwipeGestureRecognizerDirectionRight;
[imageV addGestureRecognizer:swipe];

//5 移動 實時調用
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(panAction:)];
[imageV addGestureRecognizer:pan];

//輕掃失敗算移動--->輕掃成功 移動失敗
[pan requireGestureRecognizerToFail:swipe];


//6 旋轉
UIRotationGestureRecognizer *rotation = [[UIRotationGestureRecognizer alloc]initWithTarget:self action:@selector(totationAction:)];
[imageV addGestureRecognizer:rotation];


//7 捏合
UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(pinchAction:)];
[imageV addGestureRecognizer:pinch];

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