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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:24:18+00:00 2026-06-13T13:24:18+00:00

I am trying to override URL clicks in a UIWebView object. I know that

  • 0

I am trying to override URL clicks in a UIWebView object. I know that I need to add the following code at the place where the ‘webView delegate is set’ (according to this thread):

// TODO: This should intercept URL clicks in a UIWebView, causing (for now) links to open in Safari. It doesn't work yet; possibly it's in the wrong place. Should be in the same place as we 'set the webView delegate'...
// This doesn't appear to be set anywhere yet, which is probably where I'm going wrong.
- (BOOL)webView: (UIWebView*)webView shouldStartLoadWithRequest: (NSURLRequest*)request navigationType: (UIWebViewNavigationType)navigationType {

    if ( navigationType == UIWebViewNavigationTypeLinkClicked ) {
        [[UIApplication sharedApplication] openURL:[request URL]];
        return NO;
    }

    return YES;
}

However, I have no idea where to actually put the code. One suggestion on the above thread is to place it in the viewDidLoad method, underneath a line that says “self.webView.delegate = self;”. However, my UIWebViews are actually part of a custom UIView which is called upon much like a UIAlertView (in fact, it is almost an exact replica of a UIAlertView, except that it contains a UIWebView)… So, my main app’s ViewController code does not ‘see’ the self.webView object, so I can’t set the delegate there. And, the ‘m’ file that specifies my custom UIView object (which calls the UIWebView object) doesn’t have a viewDidLoad method.

Really struggling with this, presumably because I don’t know where delegates are set.

  • 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-13T13:24:19+00:00Added an answer on June 13, 2026 at 1:24 pm

    And, the ‘m’ file that specifies my custom UIView object (which calls the UIWebView object) doesn’t have a viewDidLoad method.

    Put it in the - initWithFrame: method then:

    - (id)initWithFrame:(CGRect)frm
    {
        if ((self = [super initWithFrame:frm])) {
             webView = [[UIWebView alloc] initWithFrame:frm]; // or whatever
    
             self.webView.delegate = self;
        }
        return self;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im trying to override the add() but it will not compile public class AVLTree<E
I'm trying to follow this this tutorial to add image into imageView from URL.
I'm trying to override wordpress url rewriting for 1 specific file. My current wordpress
I am trying to setup a application to load URL in Webview and then
I'm trying to override the path that Sprockets produces in Rails, particularly for the
i am trying to override devise registrations controller so that user would be able
I'm trying to override a url in django-profiles to raise a 404 instead of
I've been trying to use the venues/add api as in the following codes: private
I am trying to override save in the modelform to add the current user
I am trying to play an url but its not playing and the code

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.