【问题标题】:UIGestureRecognizer or touchesBegan not respondingUIGestureRecognizer 或 touchesBegan 没有响应
【发布时间】:2012-12-28 16:57:43
【问题描述】:

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

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

【问题讨论】:

  • touchesBegan:withEvent: 继续 UIView 子类。也许您如何将该视图添加到屏幕上存在问题。也许你可以展示一些你如何尝试的代码?
  • @Ismael:不正确。 touchesBegan:withEvent:UIResponder 的一个方法。由于UIViewUIViewController 都继承自UIResponder,因此该方法都可以在任一位置实现。

标签: objective-c ios cocoa-touch uigesturerecognizer touchesbegan


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多