【发布时间】:2018-04-05 20:28:00
【问题描述】:
自 iOS 11 起,animated 参数似乎在 setLeftBarButtonItems( _, animated: Bool)、setRightBarButtonItems(_, animated:)、setLeftBarButton(_, animated:)、setRightBarButton(_, animated:) 方法中被忽略。
我为UIViewController 子类编写了这个简单的代码:
override func viewDidLoad() {
super.viewDidLoad()
let rightButton = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(changeRightBarButtonItem(_:)))
navigationItem.rightBarButtonItem = rightButton
}
@objc
func changeRightBarButtonItem(_ sender: Any) {
let newRightButton = UIBarButtonItem(title: "Cancel", style: .plain,
target: self, action: #selector(changeRightBarButtonItem(_:)))
navigationItem.setRightBarButtonItems([newRightButton], animated: true)
}
这在 iOS 10 上按预期运行,但在 iOS 11 上,animated 是 true 还是 false 没有区别。
它似乎是 iOS 11,但也许我错过了一些东西。任何提示让它工作?即使是解决方法也会很有趣。
【问题讨论】:
-
您是否在 ios 10 中添加了显示动画的 gif 文件,以便我们轻松了解您的问题
-
你解决了吗?
-
否,但它可以在 iOS 11.2 beta 的模拟器中再次运行。我还没有在设备上测试过。
-
在 11.2 中仍然不适合我
标签: ios uinavigationbar uibarbuttonitem ios11 uinavigationitem