0

I have cloned a project in Swift however the project has all been done programmatically (without the use of interface builder). The app uses a Parse PFLogin and PFSign up.

I would like to use a UITabBarController (in interface builder) to manage transitions of the views. Below is the code for my didFinishLaunchingWithOptions in the AppDelegate:

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

    //* Show View Controller
    controller = LoginViewController()
    controller.layerClient = layerClient

    // Register for push
    self.registerApplicationForPushNotifications(application)


    self.window!.rootViewController = UINavigationController(rootViewController: controller)
    self.window!.backgroundColor = UIColor.whiteColor()
    self.window!.makeKeyAndVisible()


    return true
}

Is setting the root view controller the same as setting as initial view controller?

What would be the best way to change this code to set the UITabBarController shown in my interface builder as the root.

Any help would be much appreciated.

Thanks

Marc

  • the storyboard should automatically set this up for you when you set the initial view controller from in the storyboard, so you shouldn't have to program it – Hamish Jan 20 '16 at 19:00
  • The issue I have is that I am integrating the code into another tabbed application. The code I have in the example sets UINavigationController as the root and I cannot seem to find a way to set the UITabBarController have already created in interface builder as the root. – Marc Heath Jan 20 '16 at 19:18

1 Answers1

1

You want to set the initial UIViewController from within the storyboard. You can do this by pointing the arrow at your desired view controller:

enter image description here

You can also do this from within the view controller's attribute inspector, by selecting the "Is Initial View Controller?" checkbox.

enter image description here

You can then remove the UIWindow code from the didFinishLaunchingWithOptions function.

Hamish
  • 78,605
  • 19
  • 187
  • 280
  • So if I would like to use the Parse PFLogin template which is 100% code I should have a LoginViewController before my TabBarController set as the initial view controller and in the login success method use a segueID to transition to the UITabBarViewController? – Marc Heath Jan 20 '16 at 19:46
  • yes, or set the `TabBarController` as your main controller and present the `LoginViewController` over it when needed – Hamish Jan 20 '16 at 20:27