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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:08:25+00:00 2026-06-11T15:08:25+00:00

I am creating a real estate app. I have a screen which displays a

  • 0

I am creating a real estate app. I have a screen which displays a listing of all entries with a thumbnail and a little text on the side. These I have loaded from the server when the app launched. Each entry can have up to 5 photos, which I do not pre-load for obvious reasons. My issue is this… when the user selects an entry, the app downloads the larger photos from the server. Depending on circumstances this can take a few seconds. Right now the app just hangs for those few seconds. I don’t know of any practical way to use an activity indicator in a list. A header space just seems like wasted space to use only to display”Loading…”. Anyone have any ideas on what I can do to let the user know that loading is in progress?

Clarification: Once an entry is selected from the list, I load up another Table View Controller which has the photos in its list of selections. I currently load the photos in the ViewDidLoad using

NSData *myPhoto = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:myURL]];
  • 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-11T15:08:26+00:00Added an answer on June 11, 2026 at 3:08 pm

    You can:

    1. Use UIActivityIndicatorView to show a spinning activity indicator in the precise spot where the image will eventually be loaded.

    2. In a separate queue download the image. While the below code uses GCD, it’s actually much better to use NSOperationQueue because on a slow network, using GCD can consume all of the available worker threads, detrimentally affecting performance on the app. A NSOperationQueue with a reasonable maxConcurrentOperationCount (such as 4 or 5) is much better.

    3. When the download is complete, dispatch the updating of the UI back to the main queue (e.g. turn off the activity indicator and set the image).

    This is sample code from a gallery app that shows how you might do it. This is probably more complicated than you need and might be hard to repurpose via cut-and-paste, but the loadImage method shows the basic elements of the solution.

    @interface MyImage : NSObject
    
    @property (nonatomic, strong) NSString *urlString;
    @property (nonatomic, strong) UIImageView *imageView;
    @property (nonatomic, strong) UIActivityIndicatorView *activityIndicator;
    @property (nonatomic, strong) UIView *view;
    @property BOOL loading;
    @property BOOL loaded;
    
    @end
    
    @implementation MyImage
    
    // I find that I generally can get away with loading images in main queue using Documents
    // cache, too, but if your images are not optimized (e.g. are large), or if you're supporting
    // older, slower devices, you might not want to use the Documents cache in the main queue if
    // you want a smooth UI. If this is the case, change kUseDocumentsCacheInMainQueue to NO and
    // then use the Documents cache only in the background thread.
    
    #define kUseDocumentsCacheInMainQueue NO
    
    - (id)init
    {
        self = [super init];
        if (self)
        {
            _view = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, IMAGE_WIDTH, IMAGE_HEIGHT)];
            _imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, IMAGE_WIDTH, IMAGE_HEIGHT)];
            _imageView.contentMode = UIViewContentModeScaleAspectFill;
            _imageView.clipsToBounds = YES;
            [_view addSubview:_imageView];
            _loading = NO;
            _loaded = NO;
        }
        return self;
    }
    
    - (void)loadImage:(dispatch_queue_t)queue
    {
        if (self.loading)
            return;
    
        self.loading = YES;
    
        ThumbnailCache *cache = [ThumbnailCache sharedManager];
    
        if (self.imageView.image == nil)
        {
            // I've implemented a caching system that stores images in my Documents folder
            // as well as, for optimal performance, a NSCache subclass. Whether you go through
            // this extra work is up to you
    
            UIImage *imageFromCache = [cache objectForKey:self.urlString useDocumentsCache:kUseDocumentsCacheInMainQueue];
            if (imageFromCache)
            {
                if (self.activityIndicator)
                {
                    [self.activityIndicator stopAnimating];
                    self.activityIndicator = nil;
                }
    
                self.imageView.image = imageFromCache;
                self.loading = NO;
                self.loaded = YES;
                return;
            }
    
            // assuming we haven't found it in my cache, then let's see if we need to fire
            // up the spinning UIActivityIndicatorView
    
            if (self.activityIndicator == nil)
            {
                self.activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
                self.activityIndicator.center = CGPointMake(self.view.frame.size.width / 2.0, self.view.frame.size.height / 2.0);
                [self.view addSubview:self.activityIndicator];
            }
            [self.activityIndicator startAnimating];
    
            // now, in the background queue, let's retrieve the image
    
            dispatch_async(queue, ^{
                if (self.loading)
                {
                    UIImage *image = nil;
    
                    // only requery cache for Documents cache if we didn't do so in the main 
                    // queue for small images, doing it in the main queue is fine, but apps 
                    // with larger images, you might do this in this background queue.
    
                    if (!kUseDocumentsCacheInMainQueue)
                        image = [cache objectForKey:self.urlString useDocumentsCache:YES];
    
                    // if we haven't gotten the image yet, retrieve it from the remote server
    
                    if (!image)
                    {
                        NSData *data = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:self.urlString]];
    
                        if (data)
                        {
                            image = [UIImage imageWithData:data];
    
                            // personally, I cache my image to optimize future access ... you might just store in the Documents folder, or whatever
    
                            [cache setObject:image forKey:self.urlString data:data]; 
                        }
                    }
    
                    // now update the UI in the main queue
    
                    dispatch_async(dispatch_get_main_queue(), ^{
                        if (self.loading)
                        {
                            [self.activityIndicator stopAnimating];
                            self.activityIndicator = nil;
                            self.imageView.image = image;
                            self.loading = NO;
                            self.loaded = YES;
                        }
                    });
                }
            });
        }
    }
    
    // In my gallery view controller, I make sure to unload images that have scrolled off
    // the screen. And because I've cached the images, I can re-retrieve them fairly quickly.
    // This sort of logic is critical if you're dealing with *lots* of images and you want 
    // to be responsible with your memory.
    
    - (void)unloadImage
    {
        // remove from imageview, but not cache
    
        self.imageView.image = nil;
    
        self.loaded = NO;
        self.loading = NO;
    }
    
    @end
    

    By the way, if the image you’re downloading is in a UIImageView in a UITableViewCell the final update back to the table might want to do something about checking to see if the cell is still on screen (to make sure it wasn’t dequeued because the UITableViewCell scrolled off the screen). In that case, the final UI update after successful download of the image might do something like:

    dispatch_async(dispatch_get_main_queue(), ^{
    
        // if the cell is visible, then set the image
    
        UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
        if (cell)
        {
            cell.imageView.image = image;
        }
    });
    

    Note, this is using the UITableView method cellForRowAtIndexPath, which should not be confused with the UITableViewController method tableView:cellForRowAtIndexPath.

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

Sidebar

Related Questions

I am creating a real estate listing website and am confused with modules I
Im creating pdfs server side with lots of graphics so maximizing real estate is
Our real estate application has a table, Events, which has historically been linked to
I'm creating a website for a real estate firm. Looking great, but the last
I'm creating a video embed page for a real estate site, where a user
We are creating a real estate website. The National Franchise site wants to pass
I am looking into creating a real-time document editing and chat application. I have
I'm creating my first real binary parser (a tiff reader) and have a question
I'm creating a Java swing app and I'm having a real hard time getting
On my app i am creating a real time trace (not sure how yet

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.