This is probably a really simple question and I apologise if it is!!
I have a view controller based application, I move from 1 xib to another using
mainviewcontroller = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle: [NSBundle mainBundle]];
[self.view addSubview: mainviewcontroller.view];
When I return back to the original view I just use
[self.view removeFromSuperview];
But I want to re-call the viewdidload method. How can I do this without having to create the view again?
addSubviewis not the correct way to have a new view controller take over and present it’s view set.Use something like this instead:
If you are using storyboards, you could always create a segue and call it programmatically or set up through the storyboard itself.
To support pre-iOS 5 devices
UIViewControlleralso has an older method (which was deprecated in iOS5 and replaced by my original suggestion).