我的网络应用程序停留在一个Web视图中,并在Safari中打开域外链接。我需要做的是添加域中的.pdf文件以在safari中打开。截至目前,他们在网络视图中打开,没有导航退出它,所以你必须强制相当的应用程序并重新启动。
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://rbc.samkingmedia.com"]]];
_webView.delegate = self;
[_webView addSubview:activityind];
timer = [NSTimer scheduledTimerWithTimeInterval:(1.0/2.0) target:self selector:@selector(loading) userInfo:nil repeats:YES];
}
-(void)loading {
if (!_webView.loading)
[activityind stopAnimating];
else
[activityind startAnimating];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
// open External Links (not beginning with www.playbuzz.org/ in Safari.app
if (
(navigationType == UIWebViewNavigationTypeLinkClicked) &&
( ![[[request URL] absoluteString] hasPrefix:@"http://rbc.samkingmedia.com/"])
) {
[[UIApplication sharedApplication] openURL:request.URL];
return NO;
}
//open Internal links in uiwebview
return YES;
}
答案 0 :(得分:0)