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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:07:54+00:00 2026-05-27T13:07:54+00:00

I have a UITableViewController that pops up a UIImagePickerController, user takes a pic, hits

  • 0

I have a UITableViewController that pops up a UIImagePickerController, user takes a pic, hits the Use button, Picker dismisses to show a custom thumbnail spinner while the image is being processed, then the spinner is replaced by the actual thumbnail at the end of processing.

At least that’s how it worked in iOS4. Now with iOS5 it just sits there processing until it’s finished, and then everything works correctly. But I want that spinner in there so the user knows something’s happening, otherwise it looks like it just hung.

So I have this:

- (void) actionSheet: (UIActionSheet *)actionSheet didDismissWithButtonIndex (NSInteger)buttonIndex {
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    picker.allowsEditing = NO;
    // yada, yada, yada
    [self presentModalViewController:picker animated:YES];
    [picker release];
}

And then this gets called when the user picks “Use”:

- (void) imagePickerController: (UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    [self dismissModalViewControllerAnimated:YES];
    [self performSelectorOnMainThread:@selector(processImage:) withObject:info waitUntilDone:NO];
    animate = true;
}

And then this gets called to perform the processing while the thumbnail is spinning:

- (void) processImage:(NSDictionary *)info
{
    UIImage *image = nil;
    NSString* mediaType = [info objectForKey:UIImagePickerControllerMediaType];
    // processing of image
    animate = false;
    [activityImageView stopAnimating];
    [activityImageView release];
    [self.tableView reloadData];
}

Like I said, it worked perfectly with iOS4, but with iOS5, no such luck. So what’s the deal? The image picker gets dismissed eventually, so why doesn’t it get dismissed immediately?

  • 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-27T13:07:55+00:00Added an answer on May 27, 2026 at 1:07 pm

    I’m not sure why there’s a disparity between iOS4 & iOS5 on this point. But your description of the UI hanging is fairly consistent with the code you’ve shown. The perform selector on main thread is doing just that, performing the selector on the main thread, which is the thread you’re calling from. Because of this setting waitUntilDone: to NO is meaningless since it’s not being sent to another thread it’s simply running in order. You would probably get the results you want just from swapping the order, like So:

    [self dismissModalViewControllerAnimated:YES];
    animate = true;
    [self performSelectorOnMainThread:@selector(processImage:) withObject:info waitUntilDone:NO];
    

    But please note that this would be risky at best, since I assume // processing of image contains no concurrency. I prefer blocks for concurrency. And on top of that I like nested blocks to make the concurrency easy to follow, for example:

    -(void)doSomeStuffInBackground{
        // Prepare for background stuff
        dispatch_async(dispatch_get_global_queue(0, 0), ^{
            // Do background stuff
            dispatch_async(dispatch_get_main_queue(), ^{
                // Update UI from results of background stuff
            });
        });
    }
    

    So with that in mind, I would suggest something more like this:

    -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
        [self dismissModalViewControllerAnimated:YES];
        [self processImage:info];
    }
    
    -(void)processImage:(NSDictionary *)info{
        animate = true;
        UIImage *image = nil;
        NSString* mediaType = [info objectForKey:UIImagePickerControllerMediaType];
    
        dispatch_async(dispatch_get_global_queue(0, 0), ^{
            // processing of image here on background thread
    
            dispatch_async(dispatch_get_main_queue(), ^{
                // update UI here on main thread
                animate = false;
                [activityImageView stopAnimating];
                [activityImageView release];
                [self.tableView reloadData];
            });
        });
    }
    

    This would offload the main work to a background thread to let the UI stay responsive.

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

Sidebar

Related Questions

I have a UITableViewController and DetailViewController that pops up when concrete row is selected.
I have a UITableViewController with an Edit button. When this is clicked, the user
I have 8 cells that are being built in my UITableViewController. I would like
I have a subclass of UITableViewController. I have code that can add/remove a UISearchBar
I have a UITableViewController that when opened displays a table of the following object:
I have a UITableViewController that contains a tableView. I want to set its scrollView
I have a UITableViewController that I have specified as a UISearchBarDelegate. Up until now,
I have a UITableViewController that when loaded gets data from a web-service and stores
I have a UIView that is pushing a UITableViewController that is contained inside of
I have a UITableViewController with a table view that works perfectly when in portrait

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.