0

I'm currently working on an application that requires a new view to be pushed to when the user clicks on a URL (This new view contains a UIWebView with browser functions). I've got this working perfectly from UIWebViews within the application, I'm just wanting to get it to work from a UITextView too.

At the moment I'm detecting that a url is being clicked on, and cancelling Safari being opened up by sub-classing UIApplication as below:

- (BOOL)openURL:(NSURL *)url
{
    if  ([self handleOpenURL:url])
        return YES;
    else
        return [super openURL:url];
}

- (BOOL)handleOpenURL:(NSURL*)url {
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    NSLog(@"%@", [NSString stringWithFormat:@"%@", request.URL]);

    return YES;
}

Which is then logging the URL I want to visit. The main issues is that I then want to push to a new UIViewController. Usually I would use this method (which works perfectly with the UIWebViews, as I'm implementing it on the UIViewContoller I'm wanting to push from):

- (void)openWebViewWithURL:(NSURLRequest *)request fromView:(UIViewController *)view withTitle:(NSString *)title

Is there any way that I can either detect the current view that has the UITextField in it (therefore passing through the current view to my method), or a way of overriding the - (BOOL)openURL:(NSURL *)url call from within the UIViewController I'm currently using?

davidford.me
  • 824
  • 1
  • 15
  • 24

1 Answers1

0

Check the UITextField's superView property.

melsam
  • 4,947
  • 1
  • 22
  • 23