且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如果已分析用户登录,则绕过登录视图

更新时间:2023-12-01 17:20:16

我以前没有使用过Parse,但是为了获得授权,我通常让AppDelegate负责初始视图控制器.

I haven't used Parse before, but for authorization I generally let AppDelegate to take care of the initial view controller.

// member variables
var storyboard : UIStoryboard?;

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    self.storyboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle());
    var currentUser = PFUser.currentUser()
    if currentUser != nil {
        self.window?.rootViewController = self.storyboard?.instantiateViewControllerWithIdentifier("ProfileSettingsViewController");
    }

    return true;
}

我非常确定这将在视图控制器内部起作用,因为在您的代码中,您没有将实例化的控制器分配给根视图控制器.但是,我认为AppDelegate应该注意更改Root View Controller,而不是UIViewControllers.

I am pretty sure this will work from inside the view controller because in your code, you didn't assign the instantiated controller to the root view controller. However, I think AppDelegate should take care of changing the Root View Controller, not UIViewControllers.

对不起,忘记提及您的错误.转到情节提要,然后单击ProfileSettingsViewController并转到侧栏中的第3个选项卡,然后会有一个情节提要ID.将名称设置为"ProfileSettingsViewController"(或任何您想要的名称),它将找到控制器. UIStoryboard.instantiateViewControllerWithIdentifier在情节提要中搜索具有给定情节提要ID的控制器.

Sorry, forgot to mention your error. Go to the storyboard and click on the ProfileSettingsViewController and go to the 3rd tab in the sidebar and there is a Storyboard ID. Set the name to "ProfileSettingsViewController" (or whatever you want) and it will find the controller. UIStoryboard.instantiateViewControllerWithIdentifier searches the storyboard for a controller with the given Storyboard ID.