是否可以将 NavigationController 限制为一组 UIViewController。看图片,我想要导航 Controller ,但只用于登录/创建用户 session 。登录后,我显然不希望用户能够返回(注销除外)。我怎样才能做到这一点?我想不通。
最佳答案
转到 Storyboard -> 选择 NavigationController -> Attributes Inspector -> 取消选中“显示导航栏”属性
然后选择Login/SignUp与TabBarController的关系,删除。
登录后,您可以将 TabBarController(或任何相关 Controller )设置为 rootViewController。当应用程序启动时,您可以在 AppDelegate.swift
中查看它。像这样的文件,
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
let storyboard = UIStoryboard(name: "Main", bundle: nil)
if Auth.auth().currentUser != nil {
let tabBarController = storyboard.instantiateViewController(withIdentifier: "tabBarcontroller") as! TabBarController
self.window?.rootViewController = tabBarController
self.window?.makeKeyAndVisible()
}
else
{
let loginNavController = storyboard.instantiateViewController(withIdentifier: "LoginNavController") as! UINavigationController
self.window?.rootViewController = loginNavController
self.window?.makeKeyAndVisible()
}
return true
}
关于ios - 将导航 Controller 限制为一组 UIViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57631874/