UIButton not works in iOS 5.x , everything is fine in iOS 6.x

后端 未结 1 1352
没有蜡笔的小新
没有蜡笔的小新 2021-02-01 10:46

By tapping simple UIButton on main UIView, additional View (subview) appears in the center of screen (subview created programmatically). On that subview I have UIButton that lau

相关标签:
1条回答
  • 2021-02-01 11:07

    Are you adding a UITapGestureRecognizer to infoView or any of it subviews?

    If that is the case, your gesture recognizer is inhibiting the UIButton action. You could use the solution provided by Kevin Ballard or cdasher on this post

    You just need to set the view that has the UITapGestureRecognizer as the delegate of that Gesture Recognizer (UIGestureRecognizerDelegate). Then you can add the following code:

    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
    {
        return ! ([touch.view isKindOfClass:[UIControl class]]);
    }
    

    And your Tap Gesture Recognizer should look like this:

    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureAction)];
    tap.delegate = self;
    [self.view addGestureRecognizer:tap];
    

    Hope this helps!

    0 讨论(0)
提交回复
热议问题