Home screen on storyboard

2

I'm using Xcode to develop an app.

In it I use storyboard for the screens. Suppose the screen structure is as follows:

I have 5 sequential screens, which one takes to the next one, until it reaches the fifth (last) screen. My home screen, set via storyboard is the number 1 screen. For navigation, I have a UINavigationController .

I would like to know how I can start the app on another screen, so that I do not lose navigation between the others. For example: Start on screen 4, but be able to return to screen 3 or go to screen 5.

Note: The code can be in Swift or Objective-C.

    
asked by anonymous 03.12.2015 / 14:25

2 answers

1

What you can do is to create the Views stack programmatically by AppDelegate.

  

I've never tried to dynamically create the entire stack, just changed the already   existing. I can not test at the moment, so I can not guarantee that it will   work, but it's a path.

Follow the implementation:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    self.window = UIWindow(frame: UIScreen.mainScreen().bounds)

    let storyboard = UIStoryboard(name: "Main", bundle: nil)

    let tela_1 = storyboard.instantiateViewControllerWithIdentifier("tela_1") as! UIViewController
    let tela_1 = storyboard.instantiateViewControllerWithIdentifier("tela_2") as! UIViewController
    let tela_3 = storyboard.instantiateViewControllerWithIdentifier("tela_3") as! UIViewController
    let tela_4 = storyboard.instantiateViewControllerWithIdentifier("tela_4") as! UIViewController
    let tela_5 = storyboard.instantiateViewControllerWithIdentifier("tela_5") as! UIViewController

    let navigationController = storyboard.instantiateInitialViewController() as UINavigationController
    navigationController.viewControllers = [tela_1, tela_2, tela_3, tela_4, tela_5]

    self.window?.rootViewController = tela_4
    self.window?.makeKeyAndVisible()

    return true
}

Note: Do not forget to change "screen_N" by the name of your actual classes.

    
03.12.2015 / 19:48
-1

I do not know what the context of your app is, but this type of navigation does not seem to have a lot of usability. Taking a look at IOS Human Interface Guide in the UI Elements - Tab Bar :

  

Thetabbargivespeopletheabilitytoswitchbetweendifferentsubtasks,views,ormodesinanapp.

ThenusingTabBaryoucanhavethiscontrolofyour5screenssothatnavigationbetweenthembecomesmoreintuitive.

Inthecaseofhowtostartfromaspecificscreen(screen4forexample) take a look at this question here about stackoverflow in Portuguese

    
14.12.2015 / 14:58