我正在创建一个应用程序,允许用户在线路或路径上方触摸。我想做一些事情,像用户应该能够利用该行的20个像素。我搜索了很多,但什么都没找到。iPhone - 触摸区域检测
-1
A
回答
1
以下是我的一个程序中的一段代码:在这里我做了类似的事情。无论用户在屏幕上点按哪个位置都会显示图像。我已将屏幕限制在某些区域,只有在龙头将被注册的地方。希望这可以帮助你:!
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
image=[UIImage imageNamed:@"anyImage.gif"];
newView = [[UIImageView alloc]initWithImage:image];
if (location.y<117 || location.y>354)
{
newView.frame = CGRectMake (location.x, location.y,87,70);
newView.center=location;
[self addSubview:newView];
}
if (location.y<90)
{
if(location.y>85)
{
if (location.x>133 || location.x<183)
{
[self shakeA]; //A method shakeA is called
}
}
}
else if (location.y<360)
{
if (location.y>354)
{
if (location.x>133 || location.x<183)
{
[self shakeB]; // Method shakeB called
}
}
}
}
+1
您的回答有帮助。但我想检测图像的触摸。例如,如果(point.x> = myimage的位置){//做些事情}。 – Smith
+1
只需找出myImage的坐标,然后使用类似的逻辑来注册图像周围的抽头。 –
相关问题
- 1. SceneKit在给定区域检测触摸
- 2. 如何在android中检测开放区域的触摸区域?
- 3. 检测iphone区域
- 4. 如何在三角形区域检测触摸
- 5. Iphone检测区域格式
- 6. UISwitch:使触摸区域大于默认触摸区域
- 7. 检测IPhone上的UIImageView触摸
- 8. iphone - 检测触摸媒体播放器
- 9. 检测iPhone上的特殊触摸
- 10. iPhone - 检测触摸UITableViewCell的子视图
- 11. 检测圆形触摸iPhone的SDK
- 12. iPhone屏幕锁定时检测触摸
- 13. iPhone - 检测触摸并取消它们?
- 14. iPhone - 的UIScrollView ...检测触摸的坐标
- 15. 我如何检测触摸UIStatusBar/iPhone
- 16. 检测触摸哪一侧触摸在iphone中的openGLES 3dbox
- 17. Android:检测用户是否触摸并拖出按钮区域?
- 18. 把屏幕划分成6个区域与检测多触摸
- 19. 如何检测我触摸特定区域?
- 20. Sencha触摸和科尔多瓦检测区域
- 21. 如何检测电晕sdk中的触摸区域?
- 22. 如何检测/处理弯曲区域上的触摸事件?
- 23. 检测UIImagePickerController的实时区域上的触摸
- 24. UIButton的可触摸区域
- 25. 获取触摸区域
- 26. 触摸区域控制
- 27. Cocos2d按钮触摸区域
- 28. 触摸不检测?
- 29. android检测触摸
- 30. android检测触摸
请更具体..... – IronManGill