后退按钮不起作用当我切换到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]
} }
在AppDelegate中将UITabBarController设置为初始值:
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
}
https://codepen.io/madhurgarg71/pen/dzgxMd
在我将UITabBarController设置为rootVC之前,一切正常。
PS:我没有使用故事板。一切都是以编程方式完成的。
答案 0 :(得分:0)
问题是我将我的TabBarController嵌入到AppDelegate中的UINavigationController中。
当我删除UINavigationController时,一切都很棒!
Gtk-WARNING **: cannot open display: