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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:26:24+00:00 2026-06-17T09:26:24+00:00

dismissViewControllerAnimated:completion: is working fine in my application, except for the delay between the dismissal.

  • 0

dismissViewControllerAnimated:completion: is working fine in my application, except for the delay between the dismissal.

[api loginWithUsername:[dict objectForKey:@"username"] andPassword:[dict objectForKey:@"password"] andSuccessBlock:^(id json) {
    NSLog(@"DONE... %@", [json objectForKey:@"status"]);
    NSString *status = [json objectForKey:@"status"];
    if([status isEqualToString:@"ok"]){
        app.user = [json objectForKey:@"data"];
        [self dismissViewControllerAnimated:YES completion:nil];
    }else{
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"could not log you in" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
        [alert show];
    }
}];

In my console I can see echo’ed “DONE… ok”, meaning the callback block was executed, however about 3-4 seconds later the modal view is finally dismissed.

What could be causing this delay?

  • 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-17T09:26:25+00:00Added an answer on June 17, 2026 at 9:26 am

    If you don’t guarantee your UI code is running on Main Thread it might run on some other and in that case, you will experience a few seconds delay!

    You can add this to make sure that dismissal is ran on main thread:

    dispatch_async(dispatch_get_main_queue(), ^{
        [self dismissViewControllerAnimated:YES completion:nil];
    });
    

    Generally, this is not an issue as most of your code will already be running on main thread, since we mostly add code that runs from UIKit methods, like viewDidLoad and such. Those methods are guaranteed to be ran on the main thread.

    The issue arises when you end up running code on another thread. One case where that can happen is for example on a completion block invocation of a networking library, where the request is done on background.

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

Sidebar

Related Questions

I have a function in my class: -(void)receiveFileName:(NSNotification *) notification { [self dismissViewControllerAnimated:YES completion:nil];
This is the code I have: -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [picker dismissViewControllerAnimated:YES completion:^(void){
I am working on facebook ios6. when i am posting the image it displays
My application supports login with facebook, but when I log out and log in
I have a project that uses the Twitter API to Tweet the users high
I am facing a problem in ios6 regarding dismissal of modalViewController Here is code
i want to share a post on facebook it works fine when i use
My FlipsideViewController's done button is not working (no crash, but not dismissing the view
I am having a problems with the dismissViewControllerAnimated method not closing down the view.
- (void)cancel { [[SHK currentHelper] hideCurrentViewControllerAnimated:YES]; } Above given is the code for cancel

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.