I have a custom init method:
- (id) initWithFrame:(CGRect ) frame andImage:(UIImage *) image
{
self = [super init];
if (self){
self.view.frame = frame;
self.imageView_.image = image;
self.imageScrollView_.frame = self.view.frame;
imageOriginalFrame = frame;
zoomedImageFrame = frame;
NSLog(@"SCREEN DIM %f AND %f", zoomedImageFrame.size.height, zoomedImageFrame.origin.y);
}
return self;
}
and here’s how I present it:
FullSizeImageViewController * fullSize = [[FullSizeImageViewController alloc] initWithFrame:imageOriginalFrame andImage:image];
if ([self.delegate respondsToSelector:@selector(fullStoryViewController:presentModalViewController:animated:)]) {
[self.delegate fullStoryViewController:self presentModalViewController:fullSize animated:YES];
}
However, surprisingly my viewDidLoad is getting called before the initWithFrame. How is this possible?
I am guessing it’s because I call super init? If not how do I do this?
Your
viewDidLoadmethod is not getting called before yourinitWithFrame:andImage:method. YourviewDidLoadmethod is getting called during yourinitWithFrame:andImage:method.Your
initWithFrame:andImage:method contains this line:which is shorthand for this:
So your method is calling the
-[UIViewController view]method. The-[UIViewController view]method is basically this:Try putting a breakpoint in your
viewDidLoadmethod. When it’s hit, look at the stack trace. You’ll findinitWithFrame:andImage:in it.