自定义导航按钮在iOS 12及以下版本上没有控制器,iOS 13正在工作
我正在尝试将CustomView与它自己的ViewController一起用作右导航栏(barbuttonitem)。此视图需要根据应用程序状态进行更新。视图的实现方式如下:自定义导航按钮在iOS 12及以下版本上没有控制器,iOS 13正在工作,ios,swift,controller,uikit,navigationbar,Ios,Swift,Controller,Uikit,Navigationbar,我正在尝试将CustomView与它自己的ViewController一起用作右导航栏(barbuttonitem)。此视图需要根据应用程序状态进行更新。视图的实现方式如下: private func addUploadStatusToNavigationController() { cloudView = UploadStatusViewController<UploadStatusNavigationView>() let tgr
private func addUploadStatusToNavigationController() {
cloudView = UploadStatusViewController<UploadStatusNavigationView>()
let tgr = UITapGestureRecognizer(target: self, action: #selector(cloudViewTapped))
cloudView.customView.addGestureRecognizer(tgr)
let cloudViewButton = UIBarButtonItem(customView: cloudView.customView)
self.navigationItem.rightBarButtonItem = cloudViewButton
cloudView.setStatus(status: uploadStatusService.getStatus())
if let btn = self.navigationItem.rightBarButtonItem?.customView {
btn.frame = CGRect(x: 0, y: 0, width: (self.navigationController?.navigationBar.frame.width ?? 0) * 0.6, height: 44)
}
uploadStatusService.delegate = self
}
private func askUserToStop() {
let alert = UIAlertController(title: "OneDrive", message: "BackupPopup.Cancel.Message".localized, preferredStyle: .alert)
let action1 = UIAlertAction(title: "Button_Title_Cancel".localized, style: .cancel, handler: nil)
alert.addAction(action1)
self.present(alert, animated: true, completion: nil)
}
如果我将一个新控制器推到NavigationStack上并再次导航回来,则手势识别器只能再次工作(iOS13)。
事实上,我希望TapGestureRecognizer能够在弹出窗口之外得到保留,并在iOS 12下工作
恐怕我不知道还能尝试什么
编辑:
总结:
- iOS 12:点击时无操作,在ViewDebugger中的视图后面无UploadStatusViewController
- iOS 13:第一次点击时的操作,第一次点击后,UploadStatusViewController在ViewDebugger中被删除
- iOS 12和13:UploadStatusViewController的其他操作,如更新其customView工作正常