PDA

View Full Version : [Resolved] Loading a Progmatically created view Controller




LastLine
Apr 27, 2011, 01:55 PM
Hey all - last dumb question (I hope)


I've got a situation whereby the following happens.

Progmatically created view (because it's easiest for what I'm doing)
User taps button, Xib based view appears using following code to load the Xib based view (InfoView2)


InfoView2 *infoView2 = [[InfoView2 alloc] initWithNibName:@"InfoView2" bundle:nil];
[self.navigationController pushViewController:infoView2 animated:YES];
[infoView2 release];

Now, I want to remove InfoView2 and go back to TapView, the progmatically created view - I feel this should be relatively simple, but every guide and tutorial I can find shows how to load Xib based views, I can't find one for non-Xib based views...am I being thick? Am I loading InfoView2 in the wrong way to start with?

I should note this is for an iPhone app - for the iPad side of the app I load InfoView2 in a popoverViewController as it's essentially the settings for the app.

Anyone able to offer some insight?

Honestly...last daft post...I promise. Small words please ;) 12 hour day coming to an end.



PhoneyDeveloper
Apr 27, 2011, 02:16 PM
This is the usual way to remove the topmost view controller.

[self.navigationController popViewControllerAnimated:YES];

LastLine
Apr 27, 2011, 02:23 PM
This is the usual way to remove the topmost view controller.

[self.navigationController popViewControllerAnimated:YES];

Doh...I was trying modalViewController....thank you.

Shawnpk
Apr 27, 2011, 09:25 PM
Use pushViewController to add the view and popViewController to remove the view.