Stopping the initial storyboard viewcontroller being created
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. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Stopping the initial storyboard viewcontroller being created
If I understand correctly, simply unchecking the “Is Initial Controller” checkbox for the viewController in the Storyboard should fix your problem. > On Nov 26, 2015, at 5:27 AM, Roland Kingwrote: > > 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. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Stopping the initial storyboard viewcontroller being created
> On Nov 26, 2015, at 7:27 AM, Roland Kingwrote: > > 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 (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com