我的解析服务器中有数据。当我的数据被提取时,我希望能够根据我的服务器中的数据更改来更改我的应用程序的根视图控制器。现在它第一次工作并选择一个根视图控制器但是当我更改服务器中的数据以测试所有方案时,我的根视图控制器不会更新。这是我的appdelagate中的代码。有人能告诉我如何解决这个问题。这是我的appdelgate的代码。如何更改此设置,以便根视图控制器根据我的解析服务器中的更改数据进行更新。
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
}
答案 0 :(得分:0)
尝试将代码移到方法中:
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}