不会调用iOS11 UIBarButtonItem操作 [英] iOS11 UIBarButtonItem action not get called
问题描述
我使用Xcode9 Beta6构建项目,在iOS10设备上正确调用了该操作,但它在iOS11设备上无法正常工作。
I used Xcode9 Beta6 to build the project, the action was called correctly on iOS10 device, however it is not work on iOS11 device.
在我的项目中,有是一些viewControllers在顶部有一个UIToolBar,而toolBar包含一些UIBarButtonItems。
In My project, there are some viewControllers have a UIToolBar on the top, and the toolBar contains some UIBarButtonItems.
有一种这样的viewController,当我点击它时,它的UIBarButtonItem动作没有被调用的UIBarButtonItem。我可以看到点击动画(图标变得暗淡并在手指释放后恢复正常)
There is one this kind of viewController, whose UIBarButtonItem action is not called when I tap the UIBarButtonItem. I can see the tapping animation (the icon become dim first and back to normal after finger released)
在 viewDidLoad $ c结束时$ c>,我打印
toolbar.items
的信息,表明目标操作设置正确。
At the end of viewDidLoad
, I print the info of toolbar.items
to indicate that target action are set properly.
< a href =https://i.stack.imgur.com/9fuAu.jpg =noreferrer>调试输出
推荐答案
我通过从视图中删除当前手势识别器并添加新手势识别器来解决此问题。比我打开视图的连接检查器并将gestureRecognizer连接添加到我的手势识别器。
I solved this problem by removing a current gesture recognizer from my view and adding a new one. Than I opened the connections inspector of my view and add gestureRecognizer connection to my gesture recognizer.
这篇关于不会调用iOS11 UIBarButtonItem操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!