我的解析服务器中有数据。当我的数据被获取时,我希望能够根据我的数据在服务器中的变化来改变我的应用程序的根视图控制器。现在它第一次工作并选择一个根视图控制器,但当我更改服务器中的数据以测试所有场景时,我的根视图控制器没有更新。下面是我的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
}发布于 2017-05-19 09:54:42
尝试将您的代码移动到method中:
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.
}https://stackoverflow.com/questions/44060031
复制相似问题