0
後退按鈕不起作用當我切換到另一個TabBarController內部的ViewController並試圖返回時。後退按鈕不起作用當我切換到TabBarController裏面的另一個ViewController
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let detailVC = NewDetailController()
navigationController?.pushViewController(detailVC, animated: true)
}
我覺得問題在於我如何創建detailVC。但不知道有什麼問題。
創建TabBarController:
class MainTabBarController: UITabBarController {
override func viewDidLoad() {
super.viewDidLoad()
// New View Controller
let newController = NewController()
let newNavController = UINavigationController(rootViewController: newController)
viewControllers = [newNavController]
} }
設置的UITabBarController作爲初始中的AppDelegate:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
window = UIWindow(frame: UIScreen.main.bounds)
window?.makeKeyAndVisible()
let mainVC = MainTabBarController()
window?.rootViewController = UINavigationController(rootViewController: mainVC)
return true
}
之前,我設置的UITabBarController作爲我rootVC一切正常。
PS:我沒有使用故事板。一切都以編程方式完成。
分享一些更深的見解plz – Mukesh
當你說「不起作用」時,你是什麼意思。什麼都沒有發生? –
是的。什麼都沒發生。 –