I have a UIViewController
called LaunchController that is launched in my iPhone app when the app first opens:
@interface LaunchController : UIViewController<UINavigationControllerDelegate, UIImagePickerControllerDelegate>
Then, when a button is clicked, I push another view controller:
MainController *c = [[MainController alloc] initWithImage:image];
[self presentModalViewController:c animated:NO];
MainController has the following constructor, which I use:
- (id)initWithImage:(UIImage *)img
{
self = [super init];
if (self) {
image = img;
NSLog(@"inited the image");
}
return self;
}
and then it has a viewDidLoad method as follows:
- (void)viewDidLoad
{
NSLog(@"calling view did load");
[super viewDidLoad];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[self.view addSubview:imageView];
NSLog(@"displaying main controller");
}
When the program runs, I see that the constructor for MainController
is called (due to the output of NSLog
), however viewDidLoad
never gets called, even though I am calling presentModalViewController
. Why is this? Why isn't viewDidLoad
being called?