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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:02:10+00:00 2026-06-15T13:02:10+00:00

This question may seem a little odd/weird, but I have two UIWebViews, one of

  • 0

This question may seem a little odd/weird, but I have two UIWebViews, one of which is set to hidden in the .xib file, and it’s delegate set to my view controller. The 2nd UIWebView is used to parse and “cleanup” the html from the hidden UIWebView and display it as a “mobilized” page to the user. There is no delegate on the non-hidden UIWebView in my .xib file.

The problem I’m having is that when the 2nd UIWebView finishes loading, the user taps on a link within the 2nd UIWebView, and it finishes loading the non parsed webpage because it didn’t send this link click back to the hidden UIWebView to be loaded so that the 2nd UIWebView can parse it when it finishes loading. My two UIWebView’s are properties in my .m file.

Is there any way I can solve this? I appreciate any responses offered! If i haven’t stated my question clearly, please let me know!

Some code:

.h:

#import <UIKit/UIKit.h>

@interface Web : UIViewController <UIWebViewDelegate>

@property (nonatomic, strong) NSURL *url;

@end

.m:

#import "Web.h"

@interface  Web()

@property (nonatomic, strong) IBOutlet UIWebView *webView2;
@property (nonatomic, strong) IBOutlet UIWebView *webView;
@property (nonatomic, strong) NSMutableString *output;
@property (nonatomic, strong) NSString *wrapper;

@end

@implementation Web

- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{   
    if(webView == self.webView2)
    {
        [self.webView loadRequest:(NSURLRequest*)request];
    }
    else
    {
        [self.webView loadRequest:(NSURLRequest*)request];
    }
    return NO;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.webView loadRequest:[NSURLRequest requestWithURL:self.url]];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{   
    [self cleanUp];

    [self.webView2 loadHTMLString:self.output baseURL:nil];
}

- (void)cleanUp
{
    NSString *input = [self.webView stringByEvaluatingJavaScriptFromString:@"document.getElementById(\"ctl_ctl_cphBody_cphCenter_divHtml\").innerHTML;"];

    NSString *breadcrumbString = [self.webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByClassName('breadcrumb')[0].outerHTML;"];

    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
        self.wrapper = @"<html><meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\"/><meta name=\"viewport\" content=\"initial-scale = 1.37,maximum-scale = 2.0\"/></html>";
    }
    else
    {
       self.wrapper = @"<html><meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\"/><meta name=\"viewport\" content=\"initial-scale = 0.57,maximum-scale = 2.0\"/></html>";
    }

    self.output = [NSMutableString stringWithString:self.wrapper];
    [self.output insertString:input atIndex:147];

    [self.output replaceOccurrencesOfString:breadcrumbString withString:@"" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [self.output length])];
}
  • 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-15T13:02:11+00:00Added an answer on June 15, 2026 at 1:02 pm

    You can implement the delegate method

    - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
    

    This lets you intercept load requests and cancel them. You can then grab the URL from the request and hand it off to your hidden webview. The only caveat is, IIRC, this method will be called even for requests that you load yourself with -loadRequest:, so you’ll want to check the navigationType argument.

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

Sidebar

Related Questions

This question may seem a little bit stackoverflow-implementation specific, but I have seen a
Hi this may seem like a weird question, but here's my situation: I have
This may seem a trivial question, but it's one that's bothered me a lot
I think the question may seem a little weird, but here's the details. The
This question may seem stupid, but, so be it! I have a stupid problem
Well this question may seem odd but it's simple - my point is if
I know this question may seem odd due to new existing alternatives, but trust
This one may seem like a simple question, but it's really got me scratching
This question may seem completely stupid, but say i have a PHP page with
this may seem a little odd, but it would make for a convenient way

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.