iOS11 UIBarButtonItem action not get called

前端 未结 6 1313
花落未央
花落未央 2021-01-12 11:06

I used Xcode9 Beta6 to build the project, the action was called correctly on iOS10 device, however it is not work on iOS11 device.

In My project, there are some view

6条回答
  •  醉酒成梦
    2021-01-12 11:43

    In my case the problem was a gestureRecognizer added to the whole main view (in order to close the keyboard) like this:

    UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKeyboard)];
    [self.view addGestureRecognizer:gesture];
    

    That gesture recognizer overrides the tap on the UIBarButtonItem, thus I solved by creating a new subview placed immediately below the navigation bar and assigning the gesture recognizer to that view and not to the whole main view.

提交回复
热议问题