Xcode: Display Login View in applicationDidBecomeActive

前端 未结 2 731
我寻月下人不归
我寻月下人不归 2020-12-17 00:57

In my app I would like to show a login screen - which will be displayed when the app starts and when the app becomes active. For reference, I am using storyboards, ARC and i

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-17 01:54

    You should init PasswordViewController viewcontroller from xib or if you store UI in Storyboard you should use Segue for present this controller.

    I can't say about another parts but that part seems to me very weird.

    My passcode view is embedded in a Navigation Controller, but is detached from the main storyboard.

    in storyboards you can store view controllers and view inside of view controllers so it's not good to store some view outside of viewcontroller because you will not be able to load this view from storyboard after receiving memory warning. Please correct me if I didn't get what do you mean.

    If we are going by your way there is no difference load PasswordViewController at applicationDidBecomeActive or at your first view controller at Storyboards because you calling present view controller from first loaded view controller. So you can do it in your first view controller. Also you can store some hidden view inside of your first viewcontroller and show this view if the user needs to login.

    I tested it. So at first your controller become loaded and then you got method applicationDidBecomeActive. So it's better to put your code inside -(void)viewDidAppear:animated method of your first viewcontroller.

    Best regards, Danil

提交回复
热议问题