我想在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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。