Re: Stopping the initial storyboard viewcontroller being created
Re: Stopping the initial storyboard viewcontroller being created
- Subject: Re: Stopping the initial storyboard viewcontroller being created
- From: Michael Babin <email@hidden>
- Date: Thu, 26 Nov 2015 11:36:12 -0600
> On Nov 26, 2015, at 7:27 AM, Roland King <email@hidden> wrote:
>
> I would like to create the main viewcontroller in my applicationDidFinishLaunching:withOptions: method (iOS) instead of having the storyboard one created automatically.
>
> I’m doing this in order to change behaviour between simulator and device as the simulator doesn’t support BlueTooth, so I need to fix in a simulated version.
>
> I have the code to create the initial view controller and fix it up
>
> let storyboard = UIStoryboard(name: "Main", bundle: nil)
> self.window?.rootViewController = storyboard.instantiateInitialViewController()
> // make a fix to the viewcontroller here
> self.window?.makeKeyAndVisible()
>
> however I’ve found that standard machinery still creates one for me so I end up with two of them, possibly with the one I want on-screen, possibly not, and the first one created doesn’t do the decent thing and release itself either, so two of them persist. (I don’t understand what’s referencing it either, when I assign to the rootViewController it ought to go away but doesn’t).
>
> How do I stop the standard storyboard initial viewcontroller load so I can do it myself.
You could remove the UIMainStoryboardFile (Main Interface) setting in your Info.plist to prevent the initial automatic interface creation/setup and then handle it yourself.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden