伙计们。我试图在safari中实现从我的webView中打开链接。有时候它很完美,有时会显示不好的访问。 这是我的代码:一些未知的事情,在Safari中打开URL
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
urlWillShow = [request mainDocumentURL];
return YES;
}
- (IBAction)openInSafari {
NSLog(@"Will try to open in safari link: %@", [urlWillShow absoluteString]);
if ([[urlWillShow scheme] isEqualToString:@"http"] || [[urlWillShow scheme] isEqualToString:@"https"]) {
BOOL canLoad = [[UIApplication sharedApplication] canOpenURL:urlWillShow];
if (canLoad == YES) {
[[UIApplication sharedApplication] openURL:urlWillShow];
}
}
}
没有足够的信息进行调试。哪一行有问题? – 2012-01-17 12:26:00
检查您在获取BAD_ACCESS的那些“有时”期间是否确实在urlWillShow中有URL。 – sElanthiraiyan 2012-01-17 12:28:48
您是使用ARC还是手动保留/释放? – 2012-01-17 12:47:09