我正在对我的应用使用快速操作,并且它们正常工作,除了导航栏丢失(无后退按钮)。这里是我的代码:使用快速操作时缺少导航栏
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
let vc = storyboard.instantiateViewController(withIdentifier: "AddViewController") as! AddViewController
switch shortcutItem.type {
case "AddIncome":
vc.type = .income
app?.mainVC.dismiss(animated: false, completion: nil)
app?.mainVC.present(vc, animated: true, completion: nil)
case "AddExpense":
vc.type = .expense
app?.mainVC.dismiss(animated: false, completion: nil)
app?.mainVC.present(vc, animated: true, completion: nil)
default:
break;
}
}
mainVC
实际上是从我目前的AddViewController
,在我的导航栏缺少VC视图控制器。
我似乎无法看到问题所在。我必须做一些额外的东西,使其正常工作?
当您以模态方式呈现视图控制器时,不会出现后退按钮。 – dan
@dan:你说得对。我以模态方式呈现它们。只需要获得导航控制器并进行推动。请提供这个答案,我会接受它。 – Kobe