ios – 如何在safari中打开不在webview中的URL

我想在safari打开一个url,outisde的应用程序,而不是在webview.

我实施了UIWebViewDelegate,但我仍然无法打开url.
基本上我无法点击网址.

以下是代码

-(void)newView:(Nsstring *)title Description:(Nsstring *)desc URL:(Nsstring *)url{
    webView =[[UIWebView alloc]initWithFrame:CGRectMake(15,17,190,190)];
    webView.backgroundColor=[UIColor clearColor];
    webView.delegate=self;
    webView.opaque = NO;
    [webView loadHTMLString:[Nsstring stringWithFormat:@"<html><body p style='color:white' text=\"#FFFFFF\" face=\"Bookman Old Style,Book Antiqua,Garamond\" size=\"5\">%@ %@</body></html>",desc,url] baseURL:nil];

    v = [[HUDView alloc] initWithFrame:CGRectMake(60,70,220,220)];

    cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
    cancelButton.frame = CGRectMake(0,30,30);
    [cancelButton setBackgroundImage:[UIImage imageNamed:@"closeBox.png"] forState:UIControlStatenormal];
    [cancelButton addTarget:self action:@selector(cancelButtonpressed) forControlEvents:UIControlEventTouchUpInside];
    [v addSubview:cancelButton];
    [v addSubview:webView];
    [self.view addSubview:v];  
}

-(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType {
    if ( inType == UIWebViewNavigationTypeLinkClicked ) {
        [[UIApplication sharedApplication] openURL:[inRequest URL]];
        return NO;
    }

    return YES;
}

解决方法

阅读评论后,我认为这是您正在寻找的:

实现这个方法

– (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...