Iphone 检测是否触摸UIView
我有一个viewController,它有一个UIView作为子视图,我想知道如何判断用户是否从viewController单击了UIView 这可能吗?Iphone 检测是否触摸UIView,iphone,objective-c,ios,xcode,Iphone,Objective C,Ios,Xcode,我有一个viewController,它有一个UIView作为子视图,我想知道如何判断用户是否从viewController单击了UIView 这可能吗? 谢谢 查看UITapgestureRecognitor文档: 您将在UIViewController中使用initWithTarget:action(传递将处理点击的选择器)实例化UIAPTgestureRecognitor。然后通过addGestureRecognizer方法将UIGestureRecognizer添加到您的UIView中
谢谢 查看UITapgestureRecognitor文档:
您将在UIViewController中使用initWithTarget:action(传递将处理点击的选择器)实例化UIAPTgestureRecognitor。然后通过addGestureRecognizer方法将UIGestureRecognizer添加到您的UIView中。您可以使用touchesBegind、touchesMoved和toucheSend方法。根据应用程序的不同,您也可以使用touchesCancelled 如果这些都不起作用,您可能需要使用UIgestureRecognitors-UIPangestureRecognitor和UIAPTgestureRecognitor 为了以防万一,您还可以使用该方法同时使用两个手势识别器
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
但这只涉及点击,如果用户在UIView中按下然后拖动手指,我想使用
触摸开始:
但我不知道如何操作。嗯,我想我误解了这个问题,以为你只想知道点击。如果您希望捕获其他用户行为,有许多手势识别器可供选择。只有当您想要捕获现有手势识别器子类未涵盖的某些行为时,我才会使用ToucheSStart。