Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/111.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c UIgestureRecognitor或Touches开始没有响应_Objective C_Ios_Cocoa Touch_Uigesturerecognizer_Touchesbegan - Fatal编程技术网

Objective c UIgestureRecognitor或Touches开始没有响应

Objective c UIgestureRecognitor或Touches开始没有响应,objective-c,ios,cocoa-touch,uigesturerecognizer,touchesbegan,Objective C,Ios,Cocoa Touch,Uigesturerecognizer,Touchesbegan,我有一个普通的应用程序。是的,这在任何地方都不起作用。如果我把它放在ViewController中,它将不起作用,如果我把它放在UIView子类中,同样,它也不起作用。我做错了什么 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"Please Work"); } 确保视图的userInteractionEnabled=YES。如果父视图的userInteractionEnabled=NO

我有一个普通的应用程序。是的,这在任何地方都不起作用。如果我把它放在ViewController中,它将不起作用,如果我把它放在UIView子类中,同样,它也不起作用。我做错了什么

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    NSLog(@"Please Work");
}

确保视图的userInteractionEnabled=YES。如果父视图的userInteractionEnabled=NO,则触摸也将丢失。如果这没有帮助,请发布代码

touchsbegind:withEvent:
进入
ui视图
子类。可能在如何将该视图添加到屏幕上存在问题。也许你可以展示一些你是如何尝试的代码?@Ismael:不正确<代码>触摸开始:withEvent:是UIResponder的一种方法。由于
UIView
UIViewController
都继承自
UIResponder
,因此该方法可以在任意位置实现。