我想在 safari 中打开一个 url,在应用程序之外而不是在 webview 中。
我实现了UIWebViewDelegate但我仍然无法打开网址。基本上我无法点击网址。
下面是代码:
-(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, 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;
}