gpt4 book ai didi

ios - Swift 4 - 带有标签栏和导航 Controller 的 3D Touch 快速操作

转载 作者:搜寻专家 更新时间:2023-11-01 07:04:10 24 4
gpt4 key购买 nike

我正在尝试从主屏幕添加 3D Touch Quick Actions,我正在使用以下代码:

        let storyboard = UIStoryboard(name: "Main", bundle: nil)
let tabVC = storyboard.instantiateViewController(withIdentifier: "TabVC") as! UITabBarController
let mainVC = storyboard.instantiateViewController(withIdentifier: "NavMoreVC") as! UINavigationController
let foodVC = storyboard.instantiateViewController(withIdentifier: "FoodVC") as! FoodTableViewController
window?.rootViewController = tabVC
self.window?.makeKeyAndVisible()
mainVC.pushViewController(foodVC, animated: true)

我试图在用户点击快捷方式后导航到 Find Food View Controller ,但上面的代码在控制台中给我一个错误:

Unbalanced calls to begin/end appearance transitions for <UITabBarController: 0x10e022600>.

有没有一种方法可以让应用在保持标签栏和导航 Controller 的同时推送到 Find Food View Controller 。谢谢!!

Navigation Structure

最佳答案

进行了更多挖掘并找到了解决方案。我在 AppDelegate 中使用了以下代码:

    let myTabBar = self.window?.rootViewController as? UITabBarController
myTabBar?.selectedIndex = 0
let nvc = myTabBar?.selectedViewController as? UINavigationController
let vc = nvc?.viewControllers.first as? MoreViewController
nvc?.popToRootViewController(animated: false)
return vc!.openPageFor(shortcutIdentifier: shortcutIdentifier)

然后在我的 MoreViewController 中,我有一个函数可以根据 shortcutIdentifier 调用不同的 segues。

关于ios - Swift 4 - 带有标签栏和导航 Controller 的 3D Touch 快速操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49073778/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com