我在我的分析服务器中有数据。当我的数据被提取时,我希望能够更改我的应用程序的根视图控制器,具体取决于我的数据在我的服务器中发生变化。现在它第一次运行并选择一个根视图控制器,但当我更改服务器中的数据以测试所有场景时,我的根视图控制器未更新。这是我的appdelagate中的代码。有人能告诉我我该如何解决这个问题。这是我的appdelgate的代码。我怎样才能改变这个,以便根视图控制器根据我的分析服务器中不断变化的数据进行更新。基于数据更新rootview控制器
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
let storyboardOne = UIStoryboard(name: "Main", bundle: nil)
let storyboardTwo = UIStoryboard(name: "Login:SIgnUp", bundle: nil)
let HomePage = storyboardOne.instantiateViewController(withIdentifier: "HomePage") as! HomePageViewController
let RestrictedPage = storyboardOne.instantiateViewController(withIdentifier: "StatusLockedOrSuspended") as! RestrictedViewController
let SignUpPage = storyboardTwo.instantiateViewController(withIdentifier: "LogInSecondSignup") as! LogInSignUpViewControllerViewController
if let window = self.window{
if PFUser.current() == nil{
window.rootViewController = HomePage
}else{
if PFUser.current()?.object(forKey: "Restricted") as? String == "" || PFUser.current()?.object(forKey: "Restricted") as? String == nil {
if PFUser.current()?.object(forKey: "username") as? String == "" || PFUser.current()?.object(forKey: "password") as? String == ""{
window.rootViewController = SignUpPage
}else{
window.rootViewController = HomePage
}
}else{
window.rootViewController = RestrictedPage
}
print("hello\(PFUser.current()?.object(forKey: "Restricted") as? String)")
}
}
return true
}
难道这就是关闭程序,然后重新打开它改变根视图? –
是的,这是什么应该发生。如果数据更改并且应用程序刷新或重新加载,则根视图控制器将被更改。你能否提出一个更新来帮助我解决这个问题。 –