“开始这个项目时,我想在拥有视图时保持整洁,所以我做了一个故事板,在那里我有我的登录视图和一个有家的故事板,也就是说,我不把Main作为故事板。
当我从sceneDelegate启动应用程序时,我可以知道我是否登录了,因为我在我的UserController中保存了相应的标志,所以这就是我如何使用其各自的UIViewController创建一个故事板或另一个故事板的方式。
我的问题是当我做登录本身,因为在这一点上,我想重定向到homeStoryBoard,它使用HomeUIViewController.通过有这些视图分开组织,我没有找到一种方法去该视图没有返回登录的可能性,因为我已经登录.我发现的方式,提高了从家里的看法,如果它是一个弹出窗口,但这不会为我工作。
我来做一个新的项目,在那里我使用了一个单一的故事板主,并有我的意见,但与此解决方案的问题,我看到的是,“返回”按钮是产生的,这将使我从主页返回到登录,这不会帮助我。
我在我的场景委托中做了下一个代码.
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
if let _ = UserDefaults.standard.string(forKey: kIsLogged) {
print("I'm loggin")
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(frame: windowScene.coordinateSpace.bounds)
window?.windowScene = windowScene
window?.makeKeyAndVisible()
let storyboard = UIStoryboard(name: "ServiceHomeViewStoryBoard", bundle: nil)
window?.rootViewController = storyboard.instantiateViewController(withIdentifier: "SB_ServiceHome")
} else {
print("I'm not loggin")
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(frame: windowScene.coordinateSpace.bounds)
window?.windowScene = windowScene
window?.makeKeyAndVisible()
let storyboard = UIStoryboard(name: "LogIn", bundle: nil)
window?.rootViewController = storyboard.instantiateViewController(withIdentifier: "LogInStoryBoard")
}
}
字符串
在我的LooginViewController我登录后功能成功.
let storyBoard = UIStoryboard(name: "ServiceHomeViewStoryBoard", bundle: nil)
let serviceHomeViewController = storyBoard.instantiateViewController(withIdentifier: "SB_ServiceHome")
self.navigationController?.pushViewController(serviceHomeViewController, animated: true)
self.navigationController?.present(serviceHomeViewController, animated: true)
self.present(serviceHomeViewController, animated:true, completion:nil)
1条答案
按热度按时间92vpleto1#
我认为你需要设置根视图控制器,而移动到家庭控制器.这里我有
scenedelegate
的扩展,你可以根视图控制器.分机号
在此
Extension
设置导航栏isNavigationBarHidden
根据您的要求设置。字符串
如何使用
型