我正在對我的應用使用快速操作,並且它們正常工作,除了導航欄丟失(無後退按鈕)。這裏是我的代碼:使用快速操作時缺少導航欄
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