Systems back button on the navigation bar.
我希望导航栏上的这个系统按钮有两个不同的操作。
1. navigationController?.popViewController
当设备方向为纵向时作为默认操作。
2. 当设备方向为横向时,将设备方向旋转为纵向。 UIDevice.current.setValue(UIInterfaceOrientation.portrait.rawValue, forKey: "orientation")
我可以通过创建一个新的 UIBarButtonItem 并将其设置为 navigationItem.leftBarButtonItem
来实现。
但它没有系统的左箭头图像和本地化字符串。 我需要此按钮具有系统的左箭头图像和本地化字符串,如系统提供的。
我试着设置像这样的 Action
navigationController?.navigationBar.backItem?.backBarButtonItem?.action = #selector(self.backToPortrait)
那是行不通的。
那么如何为这个后退按钮设置 Action 呢?
最佳答案
您不能向该系统后退按钮添加操作。有两种选择。
关于ios - 如何设置系统的后退按钮(backBarButtonItem)选择器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44792841/