Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7089963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:59:12+00:00 2026-05-28T07:59:12+00:00

I have a custom init method: – (id) initWithFrame:(CGRect ) frame andImage:(UIImage *) image

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:59:12+00:00Added an answer on May 28, 2026 at 7:59 am

    Your viewDidLoad method is not getting called before your initWithFrame:andImage: method. Your viewDidLoad method is getting called during your initWithFrame:andImage: method.

    Your initWithFrame:andImage: method contains this line:

    self.view.frame = frame;
    

    which is shorthand for this:

    [[self view] setFrame:frame];
    

    So your method is calling the -[UIViewController view] method. The -[UIViewController view] method is basically this:

    - (UIView *)view {
        if (!_view) {
            [self loadView];
            [self viewDidLoad];
        }
        return _view;
    }
    

    Try putting a breakpoint in your viewDidLoad method. When it’s hit, look at the stack trace. You’ll find initWithFrame:andImage: in it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class named Defense with custom init method as below: // initialize
I have a custom UIView that draws an image in the draw rect method.
I have an object called Communicator. Communicator has a custom init method -(id)initWithEmail:(NSString*)theEmail andPassword:(NSString*)thePassword
I have the following lines in my ~/.emacs.d/init.el (custom-set-variables '(flymake-allowed-file-name-masks (quote ( (\\.cc\\' flymake-simple-make-init)
I have an NSOperation subclass which uses Core Data. It has a custom init
I have a custom binding that creates event handlers on init. In those event
I have some map view controller and I have a custom annotation. Custom annotation
I have an NSView subclass which registers for drag files in init method like
I have a custom class with a serialize method, and I want to be
I have a mapkit application, where I've created a custom callout view. I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.