我有4个标签栏项,并将登录页面放在tab4上。登录后如何更改tab4配置文件视图。当我没有登录时,tab4是登录视图。
我已经创建了UItabbarcontroller。我可以在加载应用程序时更改tab4。但是,当我登录或注销运行时间时,无法重新加载tab4。
let logined = UserDefaults.standard.bool(forKey: "logined")
let profileVC:ProfileViewController = storyboard?.instantiateViewController(withIdentifier: "ProfilePage") as! ProfileViewController
let loginVC:LoginViewController = storyboard?.instantiateViewController(withIdentifier: "LoginPage") as! LoginViewController
if logined{
var viewControllers = self.viewControllers
viewControllers?.remove(at: 3)
viewControllers?.append(profileVC)
self.viewControllers = viewControllers
}else{
var viewControllers = self.viewControllers
viewControllers?.remove(at: 3)
viewControllers?.append(loginVC)
self.viewControllers = viewControllers
}