首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >基于数据更新rootview控制器

基于数据更新rootview控制器
EN

Stack Overflow用户
提问于 2017-05-19 09:23:14
回答 1查看 38关注 0票数 0

我的解析服务器中有数据。当我的数据被获取时,我希望能够根据我的数据在服务器中的变化来改变我的应用程序的根视图控制器。现在它第一次工作并选择一个根视图控制器,但当我更改服务器中的数据以测试所有场景时,我的根视图控制器没有更新。下面是我的appdelagate中的代码。谁能教我怎么解决这个问题。这是我的appdelgate中的代码。如何更改它,以便根视图控制器根据解析服务器中不断变化的数据进行更新。

代码语言:javascript
复制
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
}
EN

回答 1

Stack Overflow用户

发布于 2017-05-19 09:54:42

尝试将您的代码移动到method中:

代码语言:javascript
复制
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.
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44060031

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档