I have a UIViewController
called LaunchController that runs in my iPhone application the first time I open the application:
@interface LaunchController : UIViewController<UINavigationControllerDelegate, UIImagePickerControllerDelegate>
Then, when the button is pressed, I press another controller of the form:
MainController *c = [[MainController alloc] initWithImage:image]; [self presentModalViewController:c animated:NO];
MainController has the following constructor that 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 starts, I see that the constructor for MainController
is MainController
called (due to the output of NSLog
), however, viewDidLoad
never being called, although I am calling presentModalViewController
. Why is this? Why is viewDidLoad
not called?
Codeguy
source share