4

It seems to me that my iPad application loads the Storyboard File along with it's ViewController on it's own. I see an entry in the plist file for "Main storyboard file base name".

Coming from a background where I used to create "Empty Application" in Xcode, and I would then create UIViewController along with nib file, instantiate inside

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

and add to the view, and I've reference (variable) to this ViewController object

Now in this "Single View Application", I don't see any reference to the Storyboard based ViewController and I need to have a reference to do some work. please advise.

Stefan
  • 1,347
  • 2
  • 16
  • 38

1 Answers1

4

Check out this question for some sample code about accessing a view controller via the storyboard - Accessing a view controller created through Storyboard using the App Delegate

For a basic answer, you should be able to reference the "window" property. You should be able to use the properties of the "window" reference to reference your other views. There is a "rootViewController" property attached to UIWindow.

UIWindow documentation - http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIWindow_Class/UIWindowClassReference/UIWindowClassReference.html

Community
  • 1
  • 1
Kyle
  • 14,036
  • 11
  • 46
  • 61
  • 1
    Hi can you please edit the URL for the UIWindow Documentation –  Jun 06 '12 at 16:44
  • Corrected, sorry about that. I had both links pulled up in separate windows and copy/paste'd. Must have hit the same window twice. – Kyle Jun 06 '12 at 16:49
  • Thanks, just for a test, I want to revert to my old style, starting off with an "Empty Application", add a UIViewController along with it's storyboard (instead of NIB) and initialize/alloc it inside ApplicationDelegate and add to view, I tested but storyboard (NIB) wasn't displaying, I had an image inside it. –  Jun 06 '12 at 17:04
  • If you're trying to set the view up inside your AppDelegate files, you should be able to init and alloc the ViewController then set that viewController as the rootViewController for the "Window" property. `[[self window] setRootViewController:myViewController];` – Kyle Jun 06 '12 at 19:50