Have patience with me, I'm still learning Cocoa Touch. Other -viewDidLoad not being called question was unrelated to my issue, I did search.
I have FooViewController
, a UIViewController
subclass. FooViewController.xib has its File's Owner set to FooViewController. Additionally, I have Main
, whose App Delegate is MyApplication
and whose File's Owner is UIApplication
. My primary nib is set to Main.
I am able to make the view appear on the screen, using this flow (code snipped for brevity):
UIWindow *main;
-(void)applicationDidFinishLaunching:(UIApplication*)application {
[self showFooViewController];
[main makeKeyAndVisible];
}
-(void)showFooViewController {
fooViewController = [[FooViewController alloc] init];
if(![[NSBundle mainBundle] loadNibNamed:@"FooViewController" owner:fooViewController options:nil]) {
DebugF(@"Failed to load FooViewController");
return;
}
// Add the view and put it in place
UIView *view = [fooViewController view];
CGRect cur = [view frame];
cur.origin = CGPointMake(0.0f, 20.0f);
[view setFrame:cur];
[main addSubview:[fooViewController view]];
}
However, this message is not being sent to FooViewController
:
- (void) viewDidLoad {
DebugF(@"Hello!");
}
Total silence in gdb's output.
I've seen other Cocoa tutorials that show Instances and such in IB's document view, but I do not see these options in mine. Am I supposed to be instantiating fooViewController in the Nib? Did I miss a connection? In FooViewController.xib, File's Owner view is connected to the view in the Nib.
I'm sure this is a simple solution, and I have wandered down the wrong path. Halp!