ios - 将导航 Controller 限制为一组 UIViewController

标签 ios uiviewcontroller storyboard



是否可以将 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/

相关文章:

ios - UIVIew animateWithDuration 线性?

ios - Asihttprequest localizedDescription 总是英文

iphone - 检查 UIViewController 是否有任何文本字段、 TextView 或标签更改..?

ios - 将数据传递到两个 View Controller 之间的 NSMutablearray,IOS 4.3

c# - 将缓动函数应用于代码背后的动画

ios - 如何在 Xcode 7.2 中使用 UIWebViews 加载网站的 CSS 和 JS 文件?

iOS混合模式相乘

objective-c - 确保在调用 loadView 之前完全设置 UIViewController

ios - 如何使用 Autolayout 对我的 UIScrollview 设置约束?

ios - iPhone 6 plus 的屏幕尺寸问题