简单的问题在这里:我如何检测当我用户在iPhone的屏幕上滑动他们的手指?iPhone处理用户滑动
1
A
回答
3
您需要在应用程序中实现手势识别器。
在你的界面:
#define kMinimumGestureLength 30
#define kMaximumVariance 5
#import <UIKit/UIKit.h>
@interface *yourView* : UIViewController {
CGPoint gestureStartPoint;
}
@end
kMinimumGestureLength是最小距离为旅行前,他会成为一个轻扫手指。 kMaximumVariance是手指可以在y轴上的起始点之上结束的最大距离(以像素为单位)。
现在打开你的界面.xib
文件,并选择在IB视图,并确保Multiple Touch
在View Attributes.
在您的实现启用,实现这些方法。
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
gestureStartPoint = [touch locationInView:self.view];
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
CGPoint currentPosition = [touch locationInView:self.view];
CGFloat deltaX = fabsf(gestureStartPoint.x - currentPosition.x);
CGFloat deltaY = fabsf(gestureStartPoint.y - currentPosition.y);
if(deltaX >= kMinimumGestureLength && deltaY <= kMaximumVariance){
//do something
}
else if(deltaY >= kMinimumGestureLength && deltaX <= kMaximumVariance){
//do something
}
}
这是一种实现滑动识别器的方法。此外,你真的应该看看文档关于这一主题:
3
UIGestureRecognizer是你想要的。特别是UISwipeGestureRecognizer子类
0
相关问题
- 1. UNNotificationContentExtension能处理滑动吗?
- 2. jQuery用户界面滑块:移动的值(与)处理
- 3. iPhone处理动态URL
- 4. 如何处理左滑动和右滑动事件
- 5. jQuery用户界面滑块 - 处理和滚动内容不同步的动画
- 6. jQuery滑动用户界面不滑动
- 7. iPhone xCode |滑动UIView
- 8. Android左右滑动手势处理
- 9. 在触摸设备中处理滑动
- 10. 闰盘 - 处理 - 滑动手势方向?
- 11. 由于处理UITableView滚动不平滑
- 12. Iphone-Web,jQuery:如何让网页上的滑块滑动,因为用户在滑块上滑动手指?
- 13. iphone xml处理
- 14. 使用Windows Phone 8.1中的滑动处理程序滑动图像
- 15. iPhone滑块保存用户首选项
- 16. 信用卡处理库iphone
- 17. 滑块changin值移动滑块处理程序不是容器
- 18. MVC - 自动处理用户通知
- 19. iPhone滑动弹出式用户界面thingy
- 20. jQuery用户界面滑块滑动时滑动
- 21. iPhone/Android处理动态SOAP WS
- 22. 移动值在Iphone中处理
- 23. 图像处理Iphone
- 24. iPhone事件处理
- 25. iPhone事件处理
- 26. iphone,图像处理
- 27. popToRootViewControllerAnimated当用户滑动回
- 28. 图像处理 - 平滑
- 29. 双处理滑块android
- 30. 油滑预处理语句
你没有解释kMinimumVariance。 – Moshe 2010-12-06 18:24:51