coder
coder

Reputation: 10520

xib not connected to controller?

I am extremely new to iPhone development, so please forgive this post if it seems naive. I am trying to simply add a subview to my current view (if this is the best way to open a new screen on iPhone). Here is my code:

QuickCalcController *aViewController = [[QuickCalcController alloc]
                                       initWithNibName:@"QuickCalcController" bundle:nil];

aViewController.view.frame = CGRectMake(0, 100, quickCalcController.view.frame.size.width, quickCalcController.view.frame.size.height);  
[self.view addSubview: quickCalcController.view];
self.view.bounds = quickCalcController.view.bounds;

The problem is, when this code gets called, the view shown is not QuickCalcController.xib. It is MainView.xib. The file's owner is QuickCalcController... am I missing something?

Thanks in advance.

Upvotes: 0

Views: 134

Answers (1)

rckoenes
rckoenes

Reputation: 69469

You should just ask the mainViewController to present the QuickCalcController:

QuickCalcController *aViewController = [[QuickCalcController alloc]
                                       initWithNibName:@"QuickCalcController" bundle:nil];
[self presentModalViewController:aViewController animated:YES];
[aViewController release], aViewController = nil;

Then to dimiss QuickCalcController just call [self dismissModalViewControllerAnimated:YES]; in QuickCalcController.

Upvotes: 2

Related Questions