在iPad中,當您將手指放在屏幕頂部或底部邊緣之外,然後將其拖動到屏幕上時,會顯示一個菜單。你知道我該怎麼做這樣的事情?iOS檢測到屏幕左邊緣外的拖動
3
A
回答
6
1
那麼你可以做這樣的事情,這個例子是您希望您平移手勢的工作,只有當用戶刷卡從屏幕
首先的右側20像素內加手勢的情況下到你的窗口
- (void)addGestures {
if (!_panGesture) {
_panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)];
[_panGesture setDelegate:self];
[self.view addGestureRecognizer:_panGesture];
}
}
將檢查你收到的觸摸是否是一個平移手勢,然後執行你的行動因此
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
CGPoint point = [touch locationInView:self.view];
if (gestureRecognizer == _panGesture) {
return [self slideMenuForGestureRecognizer:gestureRecognizer withTouchPoint:point];
}
return YES;
}
後這裏是你如何檢查你的觸摸是否包含在你想要的區域
-(BOOL)isPointContainedWithinBezelRect:(CGPoint)point {
CGRect leftBezelRect;
CGRect tempRect;
//this will be the width between CGRectMaxXEdge and the screen offset, thus identifying teh region
CGFloat bezelWidth =20.0;
CGRectDivide(self.view.bounds, &leftBezelRect, &tempRect, bezelWidth, CGRectMaxXEdge);
return CGRectContainsPoint(leftBezelRect, point);
}
相關問題
- 1. 移動時檢測屏幕邊緣UIImageView
- 2. 只有左右屏幕邊緣的Sprite Kit衝突檢測
- 3. 檢測用戶何時到達設備的左側或右側屏幕邊緣
- 4. 檢測屏幕的UIView動畫的邊緣
- 5. `touchesBegan:withEvent:`在屏幕左邊緣延遲了
- 6. 實現拖動項目到屏幕邊緣特徵
- 7. iOS CoreImage邊緣檢測
- 8. 解決一個邊緣左邊的屏幕寬度的一半
- 9. 檢測物體接觸屏幕邊緣的情況
- 10. 錨窗到WPF中的屏幕邊緣
- 11. 將div伸展到屏幕的邊緣
- 12. CSS - 對齊格到屏幕的邊緣
- 13. 與屏幕邊緣滑動手勢
- 14. Viewpager只能從屏幕邊緣滑動
- 15. 修改JQuery easyTooltip來檢測屏幕邊緣
- 16. jQuery工具提示檢測屏幕邊緣
- 17. Three.js旋轉矢量和屏幕邊緣檢測
- 18. HTML表格填充到屏幕邊緣
- 19. 將DrawableRight推到屏幕邊緣
- 20. UIScrollView ContentOffset未達到屏幕邊緣
- 21. 將JFrame捕捉到屏幕邊緣
- 22. 用UIPanGestureRecognizer轉換到屏幕邊緣。
- 23. 使彈丸過渡到屏幕邊緣
- 24. UIViewController嵌套視圖到屏幕邊緣
- 25. iOS 7旋轉設備未檢測到橫向屏幕邊界
- 26. 檢查動畫是否在Winform中的屏幕邊緣
- 27. 當它在iOS中碰到屏幕邊緣時變換圖像
- 28. 使用KIF從屏幕邊緣滑動(測試UIScreenEdgePanGestureRecognizer)?
- 29. 將默認interactivePopGestureRecognizer擴展到屏幕邊緣之外嗎?
- 30. SQLITE邊緣檢測
你可以使用手勢 –