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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:52:47+00:00 2026-06-04T12:52:47+00:00

How do i check if the UIImageView did fail to load the image ?

  • 0

How do i check if the UIImageView did fail to load the image ?

I have a UIImageView loading an image from URL like so:

      [MyImageView setImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://exampleUrl.com/images/the_image.png"]]]];

but if the image for some reason is not available i want to load an alternative image.

How would i approach this problem ? Can i add some kind of observer ?

Alternatively can i check when the ImageView did finish loading the image to check if the image is nil ?

Thanks !

  • 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-04T12:52:48+00:00Added an answer on June 4, 2026 at 12:52 pm

    You are making a synchronous request on main thread and not even checking error conditions like if it fails or network connection times out.

    You can use this instead:

    [NSURLConnection sendAsynchronousRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://exampleUrl.com/images/the_image.png"]] queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse* response, NSData* data, NSError* error){
    
    if(error)
    {
      // Error Downloading image data
    }
    else
    {
      [MyImageView setImage:[UIImage imageWithData:data]];
    }
    }];
    

    Using Asychronous url load using NSURLConnection. When connection has finished downloading data or error occured it notifies via connection handler block.

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

Sidebar

Related Questions

I want to check if uiimageview is populated, then i have a button i
I have an UIImageView and taking the raw touch input. I need to check
I'd like to check the color set for a background on a UIImageView. I've
I have created a check box using the uiimageview and i have placed the
Say I have a UIImageView that contains an image of an object that is
I have problem with loading images from the Documents folder of iPhone application into
Check this URL: http://api.stackoverflow.com/1.1/users/811785/questions?sort=votes It's a URL from StackOveflow's API. The returned JSON is
Check out this jsbin . I have a form with a custom button that
I am changing the image in UIImageView based on accelerometer input. The images are
I have an image that i rotate to face the touchLocation of the user,

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.