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

  • Home
  • SEARCH
  • 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 7828295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:17:52+00:00 2026-06-02T10:17:52+00:00

I give up. Can’t seem to make this very basic thing work. Please help…

  • 0

I give up. Can’t seem to make this very basic thing work. Please help…

I’m trying to load an image from a URL onto a scrollable, pinch/zoomable screen.

Here’s my code snippet which yields a blank white screen. I’ve chosen to place it in viewDidAppear:

@property (weak, nonatomic) UIScrollView *scrollView;
@property (weak, nonatomic) UIImageView *imageView;

…

- (void)viewDidAppear:(BOOL)animated {

    NSData *photoData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:urlForImage]];
    UIImage *photoImage = [[UIImage alloc] initWithData:photoData];

    self.scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame];
    [self.scrollView setContentSize:photoImage.size];
    [self.scrollView setMinimumZoomScale:1];
    [self.scrollView setMaximumZoomScale:5];
    [self.view addSubview:self.scrollView];

    self.imageView = [[UIImageView alloc] initWithImage:photoImage];
    [self.imageView setContentMode:UIViewContentModeScaleAspectFit];
    [self.imageView setFrame:self.view.frame];
    [self.scrollView addSubview:self.imageView];

}

I’ve also implemented viewForZoomingInScrollView:

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{ 
    return self.imageView;
}

I’m getting a white screen. What am I missing? Thank you in advance.

  • 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-06-02T10:17:53+00:00Added an answer on June 2, 2026 at 10:17 am

    As @jonkroll suggests, the problem is that you’re assigning a retained object to a weak variable. It’s not like a IBOutlet, which should generally be weak. Here you definitely want to change it to strong and it should fix your problem.

    To demonstrate the current problem, if you put the following statement immediately after you alloc/init statements for the scrollView, for example, you may be surprised to see it’s nil, because ARC has already released it for you, e.g.:

    NSLog(@"scrollView = %p", scrollView);
    

    Make them strong, and you’re ok. If you replace your self.scrollView and self.imageView with just scrollView and imageView, you’ll probably see the compiler warnings.

    Alternatively, if you don’t need these vars for other reasons, you can also forget about making them properties at all and make them local vars of the viewDidLoad method (the views themselves will be retained when you add them as subviews … no reason to make them properties or ivars unless you need the vars for some reason in some other method). I don’t like to add properties or ivars unless I need to. If you need them, fine, you need them, but if you don’t, make them local viewDidLoad vars.

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

Sidebar

Related Questions

any help you can give is very gratefully accepted. I've been looking at this
Can someone give me a little help with this? i have three PHP SQL
Can someone please help me in writing the exact query, which can give me
Maybe its a very dumb question but I hope you can give me some
Do anyone can give example of function composition? This is the definition of function
What all parameters can we give to exec() function. Please give me the link
is there anyone who can give me a vital and simple explanation im trying
Thanks for any help that you can give me. I need a batch file
I hope someone can give me a hand figuring this out. I have been
If anyone can give any insight here it would be very much appreciated. I

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.