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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:04:41+00:00 2026-06-11T06:04:41+00:00

I am posting a notification from the UIPopoverController back to my main view, which

  • 0

I am posting a notification from the UIPopoverController back to my main view, which then immediately calls dismissPopoverAnimated, and then goes about doing some fairly heavy work loading web views. All of this code works; the problem is that on some older ipads, the popover is not actually dismissed until after the cpu intensive work is completed (verified in debugger). This causes the popover to appear to hang for second after being dismissed. How can I ensure the popover is dismissed immediately instead of doing the intensive code first?

The method which responds to the notification is as follows:

- (void)changeDefaultView:(NSNotification *)note
{
    [self closePopover];

    int i;
    for(i = 0; i < [arrWebViewControllers count]; i++)
    {
        WebViewController *wvc = [arrWebViewControllers objectAtIndex:i];
        [[wvc webview] stopLoading];
        [[wvc webview] removeFromSuperview];
        [[wvc imageview] removeFromSuperview];
        wvc = nil;
    }

    [arrWebViewControllers removeAllObjects];
    [arrLinks removeAllObjects];
    [arrImageViews removeAllObjects];

    [self loadCategory:[note object]];

    [self addWidgetsToView];
}

and closePopover is:

- (void)closePopover
{
    if(popover != nil)
    {
        [popover dismissPopoverAnimated:YES];
        popover = nil;
    }
}
  • 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-11T06:04:43+00:00Added an answer on June 11, 2026 at 6:04 am

    The animation of the disappearing popover happens on the main run loop; if you’re doing heavy CPU work on the main thread, then the loop won’t get a chance to run. So what you need to do is to perform your work on a background thread.

    The currently-preferred way to do this is using Grand Central Dispatch, like so: (I’m assuming that loadCategory: is the CPU-intensive operation)

    - (void)changeDefaultView:(NSNotification *)note
    {
        [self closePopover];
    
        int i;
        for(i = 0; i < [arrWebViewControllers count]; i++)
        {
            WebViewController *wvc = [arrWebViewControllers objectAtIndex:i];
            [[wvc webview] stopLoading];
            [[wvc webview] removeFromSuperview];
            [[wvc imageview] removeFromSuperview];
            wvc = nil;
        }
    
        [arrWebViewControllers removeAllObjects];
        [arrLinks removeAllObjects];
        [arrImageViews removeAllObjects];
    
        // perform the expensive operation on a background thread
        dispatch_async(dispatch_get_global_queue(0, 0), ^{
    
            [self loadCategory:[note object]];
    
            // now get back onto the main thread to perform our UI update
            dispatch_async(dispatch_get_main_queue(), ^{
    
                [self addWidgetsToView];
    
            });
    
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to create a method for posting a notification through the NSNotificationCenter and then
I want to know how long does it take from posting a notification to
I am posting different notifications to the notification bar. All are having different id's
When posting from JS, PHP (5.3.8) returns some line returns in excess. For example:
When posting back to my controller my model is populated with correct values and
I am posting pictures from a facebook application to a facebook fan page album
I've written a custom notification to Airbrake from a Ruby EM server we run
I am using notifications to pass data from a detail view controller to the
I have the code posting the notification handler IONotificationPortRef notificationPortRef = IONotificationPortCreate(kIOMasterPortDefault); if (!notificationPortRef)
If the class is a custom class, after posting the notification, the selector corresponding

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.