info: xcode 4.3.2, iOS5, using storyboard.
Created project from xcode’s “Tabbed Application” template.
Did:
@implementation SUSecondViewController
UIImagePickerController *pic;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
pic = [[UIImagePickerController alloc] init];
pic.delegate = self;
// [pic setSourceType:UIImagePickerControllerSourceTypeCamera];
[self presentModalViewController:pic animated:YES];
}
When I click the tab the first time, the camera app is displayed.
When I click the tab the second time, the default view from the template is displayed, however I want the camera to be displayed every time the tab is clicked.
How can I make the camera appear every time I click a specific tab (with f.ex. a camera icon) ?
viewDidLoad only happens when the view is loaded.
If a view disappears / reappears it’s not guaranteed that the view will get unloaded / loaded.
Maybe because there still is a strong pointer to the viewController somewhere, and the system doesn’t need to free up some memory.
If you want to get it called every time the view appears, place that code in UIViewControllers
method instead of
You might also want to take a look here:
http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/ViewLoadingandUnloading/ViewLoadingandUnloading.html#//apple_ref/doc/uid/TP40007457-CH10-SW1