selecting alternative first view controller from story board at application startup

后端 未结 4 1290
伪装坚强ぢ
伪装坚强ぢ 2020-12-29 08:04

I\'ve just started on iOS programming and so far the tutorials and answers I found here have been a great help to move forward. However, this particular problem has been bum

4条回答
  •  失恋的感觉
    2020-12-29 08:59

    I had hardly used storyboard & probably this is not the exact answer to your question. But I will suggest you some way what I did in my project created without using a storyboard.

    In didFinishLaunchingWithOptions AuthenticationViewController is the first view loaded. It asks login credentials. Once entered it will enter the actual ViewControllers(viz. TabBar &all..) used by project.

    Interesting feature added to project is, when you enter credentials I popped up an UIAleretView that asks user to choose one of the three options.

    1. Save Credentials without passcode
    2. Save Credentials with passcode
    3. Dont save credentials

    Here pass code is nothing but 4digit number entered by user. Whenever he wants to 'Save Credentials with passcode', I pushViewController that shows NumberPad instad of default keyboard & popviewController when it finishes entering of pin. If user 'Dont save credentials' & later on while playing the app wants to go for other authentication options then I added the last tab of TabBarController as 'Settings' tab inside which I allow user to choose one of the Authentication options, popped as UIAlertView in the beginning of app start after login.

    Dont forget to Save credentials in keychain

    In a nutshell,

    1. AuthenticationViewController-> check if login credentials are stored in keychain

    1.1. If not stored(i.e. 3. Dont save credentials)-> then show Login page.

    1.2. If credentials are saved in keychain-> extract them & see if it is tied with passcode.

    1.2.1. If it is tied with passcode(i.e. 2. Save Credentials with passcode )-> then show passcode page.

    1.2.2. If it is not tied (1. Save Credentials without passcode)-> then show/load you project's TabBarController hierarchy or other stuff. here actually your app start.

提交回复
热议问题