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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:59:41+00:00 2026-06-14T14:59:41+00:00

This is a Q&A post. To inform the many other users I saw who

  • 0

This is a Q&A post. To inform the many other users I saw who struggled with this issue as I browsed through StackOverflow’s database. None of these users ever got a solid answer (and most of them were posing the question years ago so I wasn’t going to bump the post).


The issue many struggled with is as follows:

When you try to load a page in a UIWebView and the page then loads another page maybe via an iFrame or it loads an advertisement through javascript you end up getting the page loading function called again and if you are using a UIActivityIndicator it will get called again as well and annoy your users.

The fix for this is to store the previous MainURL and to check the new MainURL that is trying to be loaded, if they match than ignore the load function. (Example code in my answer below)

**An example of a webpage that will call the webViewDidStartLoad method additional times after the web page has already really loaded would be: http://www.speakeasy.net/speedtest/

  • 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-14T14:59:42+00:00Added an answer on June 14, 2026 at 2:59 pm
    //Define the NSStrings "lastURL" & "currentURL" in the .h file.
    //Define the int "falsepositive" in the .h file. (You could use booleans if you want)
    //Define your UIWebView's delegate (either in the xib file or in your code `<UIWebViewDelegate>` in .h and `webView.delegate = self;` in .m viewDidLoad)
    
    - (void)webViewDidFinishLoad:(UIWebView *)webView {
        lastURL = [NSString stringWithFormat:@"%@", webView.request.mainDocumentURL];
        if (falsepositive != 1) {
            NSLog(@"Loaded");
            //hide UIActivityIndicator
        } else {
            NSLog(@"Extra content junk (i.e. advertisements) that the page loaded with javascript has finished loading");
            //This method may be a good way to prevent ads from loading hehe, but we won't do that
        }
    }
    
    -(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType; {
        NSURL *requestURL = [request mainDocumentURL];
        currentURL = [NSString stringWithFormat:@"%@", requestURL]; //not sure if "%@" should be used for an NSURL but it worked..., could cast `(NSString *)` if we *really* wanted to...
        return YES;
    }
    
    - (void)webViewDidStartLoad:(UIWebView *)webView {
        if ([currentURL isEqualToString:lastURL]) {
            falsepositive = 1;
            NSLog(@"The page is loading extra content with javascript or something, ignore this");
        } else {
            falsepositive = 0;
            NSLog(@"Loading");
            //show UIActiviyIndicator
        }
    }
    
    //make sure you read the //comments// at the top of this code snippet so that you properly define your .h variables O:) Thanks!
    
    
    
    //
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my fort post on stackoverflow. I have searched many similiar Q&A's on
I send to my sever this POST petition: name=pepito&friends=pep+mar And I notice what arrives
This is my string: <link href=/post?page=4&amp;tags=example rel=last title=Last Page> From there I am trying
Please review this Stackoverflow post. I have the same PHP problem as bob_cobb. Here's
I saw a similar post that was trying to do this same thing with
Came across this post & it says referential integrity handled by the DB is
How can I convert this to preg_match? $urlregex = (https?|ftp)://([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&;%$-]+)*@)*((?:(25[0-5]|2[0-4]\d|[01]\d{2}|[1-9]\d|[1-9])\.){3}(25[0-5]|2[0-4]\d|[01]\d{2}|[1-9]\d|[1-9]|0)|localhost|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:\d+)*(($|[a-zA-Z0-9.,?'+\\&;%\$#=~_-]+))*; if (!eregi($urlregex, $_POST['url'])) {
For Eg : Follow @SoccerBible, RT this & if Ronaldo scores https://bit.ly/133/com tonight we'll
From this question & the answers - What is the correct answer for cout
Spreadsheet Sheet3 looks like this: S&P 500 DJIA 1/1/1991 795.4476 2973.09 1/2/1991 786.3856 2947.1

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.