0

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.

1
  • Do you mean [self.view addSubview:aViewController.view];? Commented Sep 15, 2011 at 15:30

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I just tried this code, but nothing happened when I tried to open the screen(I am trying to open it from a TableView item).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.