iphone 手势编程---值得回忆的API
生活随笔
收集整理的這篇文章主要介紹了
iphone 手势编程---值得回忆的API
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
basis gestrues
include:
Tap :To press or select a control or item(analous to a single mouseclick) .
Drag:
Flick: To scroll pan quickly
Swipe:
Double Tap:
Pinch? Open:
Pinch? close:
Touch and hold:
Shake::
可以通過4個方法通知響應者有關觸摸和手勢的情況,當用戶第一次觸摸屏幕時,iphone將查找touchesbegan:方法響應者。
若要查清用戶第一次開始進行的手勢或者輕擊屏幕的時間。請再視圖或者控制器中實現這個方法。
touchesbegan:
{????NSUInteger numTaps=[[touches anyObject] tapcount];
?????NSUIteger? numtouches=[touches count];
?????
}
輕掃的代碼:
?首先在touchesBegan里 獲得初始位置?代碼如下
??? UITouch*touch=[touches anyObject];
???gestureStarPoint=[touch locationInView:self.view];
首先設定最小縱向長和最大橫向長
如:kMinimnumGestureLength??KMaxmnumGestureVariance
?然后在move方法里邊代碼如下
??? CGFloatKmininumlenth=12,KmaxnumVariance=36;
??? UITouch*touch=[touches anyObject];
??? CGPointcurrentPoint=[touch locationInView:self.view];
??? CGFloatdeltaX=fabsf(gestureStartPoint.x-currentPoint.x);
??? CGFloatdeltaY=fabsf(gestureStartPoint.y-currentPoint.y);
???
??? if(deltaX>=Kmininumlenth&&deltaY<=KmaxnumVariance){
??????
??? }
???else? if(deltaY>=Kmininumlenth&&deltaX<=KmaxnumVariance){
///
????????? }
?
include:
Tap :To press or select a control or item(analous to a single mouseclick) .
Drag:
Flick: To scroll pan quickly
Swipe:
Double Tap:
Pinch? Open:
Pinch? close:
Touch and hold:
Shake::
可以通過4個方法通知響應者有關觸摸和手勢的情況,當用戶第一次觸摸屏幕時,iphone將查找touchesbegan:方法響應者。
若要查清用戶第一次開始進行的手勢或者輕擊屏幕的時間。請再視圖或者控制器中實現這個方法。
touchesbegan:
{????NSUInteger numTaps=[[touches anyObject] tapcount];
?????NSUIteger? numtouches=[touches count];
?????
}
輕掃的代碼:
?首先在touchesBegan里 獲得初始位置?代碼如下
??? UITouch*touch=[touches anyObject];
???gestureStarPoint=[touch locationInView:self.view];
首先設定最小縱向長和最大橫向長
如:kMinimnumGestureLength??KMaxmnumGestureVariance
?然后在move方法里邊代碼如下
??? CGFloatKmininumlenth=12,KmaxnumVariance=36;
??? UITouch*touch=[touches anyObject];
??? CGPointcurrentPoint=[touch locationInView:self.view];
??? CGFloatdeltaX=fabsf(gestureStartPoint.x-currentPoint.x);
??? CGFloatdeltaY=fabsf(gestureStartPoint.y-currentPoint.y);
???
??? if(deltaX>=Kmininumlenth&&deltaY<=KmaxnumVariance){
??????
??? }
???else? if(deltaY>=Kmininumlenth&&deltaX<=KmaxnumVariance){
///
????????? }
?
總結
以上是生活随笔為你收集整理的iphone 手势编程---值得回忆的API的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ARM嵌入式核心板介绍
- 下一篇: 计算机网络管理(第二版)自学教程