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 6721005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:16:44+00:00 2026-05-26T09:16:44+00:00

There is a UIViewController that uses a UIImageView , and that image view is

  • 0

There is a UIViewController that uses a UIImageView, and that image view is initialized with image data (NSData). It does not use a XIB, but creates its view programmatically:

- (void)loadView
{
    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageWithData:self.imageData]];
    scrollView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    scrollView.contentSize = imageView.bounds.size;
    scrollView.delegate = self;
    [scrollView addSubview:scrollView];
}

That data has to be set by another controller which allocs, inits, and pushes this view controller onto the navigation controller:

ImageViewController *imageViewController = [ImageViewController alloc] init];
imageViewController.imageData = someData;
[self.navigationController pushViewController:imageViewController animated:YES];

How do I know that everything that needs to be done, which in this case, is setting the data, is done before loadView is called? Or, do I not know, and I have to create a custom initializer, or somehow call loadView again when the view controller receives the data?

I have faced many similar situations where I was confused about what will happen, such as with UITableViewControllers.

  • 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-26T09:16:45+00:00Added an answer on May 26, 2026 at 9:16 am

    How do I know that everything that needs to be done, which in this case, is setting the data, is done before loadView is called?

    Because the documentation mentions that view controllers do not load their views until they are needed. And the view controller’s view is not needed before the navigation controller tries to push it on screen.

    Besides, the proper place for assigning the imageData to your image view is probably viewDidLoad (“If you want to perform any additional initialization of your views, do so in the viewDidLoad method.”). And your loadView method will not do anything visible in its current form. You have to assign a view to the view controller’s view property in that method.

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

Sidebar

Related Questions

I have a main view that manually creates a UIViewController (not a UINavigationController) and
In iOS4, I want to use MPMoviePlayerController. I have a UIViewController that I pass
I have a UINavigationController with a UIViewController (vc1) as the root view controller. There
so I have subclassed a UIViewController that I create. The question is, is there
I'm interested in having a UIViewController that supports all orientations and cleanly uses two
I have a UIViewController that manages the display of some data. When the user
I have a UIViewController that has a XIB. I don't want to get rid
I'm developing an iPhone application. Is there any default state/accessor in UIViewController that tells
Possible Duplicate: Create a UIViewController that contain a UIViewController I have a parent view
I have a modal view controller that takes another UIViewController as delegate. My doubt

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.