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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:43:00+00:00 2026-05-18T11:43:00+00:00

I want to load a PDF file in a modal view controller. Since the

  • 0

I want to load a PDF file in a modal view controller.
Since the moment that I don’t know the size of the file, I want to load it on a separate thread, so:

- (void)viewDidLoad {
  [super viewDidLoad];
  [[UISharedApplication sharedApplication] setNetworkActivityIndicatorVisibile:YES];
  [NSThread detachNewThreadSelector:@selector(loadPDF) toTarget:self withObject:nil];
}
- (void)loadPDF {
  NSAutoreleasePool *threadPool = [[NSAutoreleasePool alloc] init];

  [self.webView loadRequest:[NSURLRequest requestWithURL:url]];

  [threadPool release];

  [self performSelectorOnMainThread:@selector(showPDF) withObject:nil waitUntilDone:NO];
}
- (void)showPDF {
  [self.webView setHidden:NO];
  [self.spinner stopAnimating];
  [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
}

The method works pretty good in other files (at least I guess) where I parse some XML data, but here doesn’t. Commenting:

[self performSelectorOnMainThread:@selector(showPDF) withObject:nil waitUntilDone:NO];

lets me to see the spinner and the activity indicator on the top. So I think that:

[self.webView loadRequest:[NSURLRequest requestWithURL:url]];

doesn’t wait until finish and gives the control back to the caller. How can I fix it?

  • 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-18T11:43:00+00:00Added an answer on May 18, 2026 at 11:43 am

    You can’t/shouldn’t (have got it to work once) update the UI on a separate thread, you should to it all on the main. As I believe webView is a UIWebView this is probably the reason.

    Although you are changing the webview from hidden to visible on the main thread, all the updating and creating of the actual UIWebView is not.

    Best thing to do is create the data from the URL then performSelectorOnMainThread and pass the data to a method on the main thread that updates the UIWebview with the data.

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

Sidebar

Related Questions

I have an existing pdf, and i want to load it, change its orientation
at first sorry my bad English I want load model in my plugin controller
I want to load an image via css that stretches to the entire screen.
I want to load PNG-file from resources. There is a roughly MFC-way (with CResourceStream
I want to load multiple variables into one .mat file at the end of
I want to load a palette from a bitmap file I have created. The
I want to load PDFs or Images into a View, but when the source
Im want to open pdf file in web browser, but i got following error,
I am working on a project that requires file uploads. I want to make
I'm trying to create a method that will send a PDF file directly to

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.