[英]iOS11 UIBarButtonItem not working
I have an app that is live in the store. 我在商店里有一个应用程序。 I am trying to get it ready for the iOS11 release but have run into an annoying problem. 我试图为iOS11版本做好准备,但遇到了烦人的问题。
None of the UIBarButtonItem
s in the app are working properly. 应用程序中的UIBarButtonItem
都没有正常工作。 The leftBarButtonItems are clickable but the click area is slightly to the right of the item. leftBarButtonItems是可点击的,但点击区域略微位于项目的右侧。 The rightBarButtonItems are not working at all! rightBarButtonItems根本不起作用! I have added the items both via the storyboard and via code but none of them seem to be working. 我通过故事板和代码添加了这些项目,但它们似乎都没有工作。 Please help! 请帮忙!
Here's an example:- 这是一个例子: -
navigationItem.rightBarButtonItem = UIBarButtonItem(title: NSLocalizedString("Save", comment: "save button title"), style: UIBarButtonItemStyle.plain, target: self, action: #selector(VC.rightBarButtonClicked(_:)))
Had the same issue. 有同样的问题。 It came down to an extension on UIButton in a file called "UIButton+MinimumTouchArea.swift" in our project which overrides UIButton.hitTest and breaks UIBarButtonItem in iOS 11. It took us a the whole day to figure out! 它归结为UIButton在我们项目中名为“UIButton + MinimumTouchArea.swift”的文件中的扩展,该文件覆盖了UIButton.hitTest并在iOS 11中打破了UIBarButtonItem。我们花了一整天的时间才弄明白!
iOS11 UIBarButtonItem action not get called 不会调用iOS11 UIBarButtonItem操作
ran into the same, solution for me was to build with xcode 8.3 instead (devices with ios11 running the app build by 8.3 worked great) 遇到了同样的问题,我的解决方案是用xcode 8.3构建(运行应用程序构建的ios11的设备运行良好)
Use Xcode 8 with iOS 11 you can use this workaround to debug ios11 devices on xcode 8.3 在iOS 11中使用Xcode 8,您可以使用此解决方法在xcode 8.3上调试ios11设备
Yes there bug in iOS 11
so you can use another way for it. 是的, iOS 11
存在错误,因此您可以使用其他方式。
Use interactivePopGestureRecognizer
like 使用interactivePopGestureRecognizer
类的
self.navigationController?.interactivePopGestureRecognizer?.delegate = self as! UIGestureRecognizerDelegate
and implement delegate method like 并实现委托方法
func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
guard gestureRecognizer == interactivePopGestureRecognizer else {
return true // default value
}
// Write you code here.
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.