如何处理webView跳转
2024-10-12 19:36:14
- (void)webView:(UIWebView *)wv didFailLoadWithError:(NSError *)error {
// Give iOS a chance to open it.
NSURL *url = [NSURL URLWithString:[error.userInfo objectForKey:@"NSErrorFailingURLStringKey"]];
if ([error.domain isEqual:@"WebKitErrorDomain"]
&& error.code == 101
&& [[UIApplication sharedApplication]canOpenURL:url])
{
[[UIApplication sharedApplication]openURL:url];
return;
}
// Normal error handling…
}
- (BOOL)webView:(UIWebView *)wv shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
// Determine if we want the system to handle it.
NSURL *url = request.URL;
if (![url.scheme isEqual:@"http"] && ![url.scheme isEqual:@"https"]) {
if ([[UIApplication sharedApplication]canOpenURL:url]) {
[[UIApplication sharedApplication]openURL:url];
return NO;
}
}
return YES;
}
- (void)webView:(UIWebView *)wv didFailLoadWithError:(NSError *)error {
// Ignore NSURLErrorDomain error -999.
if (error.code == NSURLErrorCancelled) return;
// Ignore "Fame Load Interrupted" errors. Seen after app store links.
if (error.code == 102 && [error.domain isEqual:@"WebKitErrorDomain"]) return;
// Normal error handling…
}
转自:http://stackoverflow.com/questions/4299403/how-to-handle-app-urls-in-a-uiwebview
最新文章
- 兼容IE8 input的placeholder的文字显示
- PB函数大全
- zhuang 自定义Xcode代码模板:Code Snippet
- 无线路由器WDS 桥接设置方法
- ASP.NET Web API身份验证和授权
- TreeView 读取 xml 显示节点
- Linux有问必答:如何在Linux中修改环境变量PATH
- PHP之set_error_handler()函数讲解
- Mac下开发常用目录
- poj2817WordStack(状压)
- 强大的数据库查询工具Database.NET 9.4.5018.42
- ubuntu 上配置python +selenium环境
- yii创建控制台命令
- codeforces369A
- zoj3195 联通树上三个点的路径长
- 解决提交按钮在IE浏览器正常在360浏览器不可用
- Jpa实体类生成图解
- 基于线程实现的生产者消费者模型(Object.wait(),Object.notify()方法)
- js 弹出新页面,避免被浏览器、ad拦截的一种办法
- 修改RocketMQ的NameServer端口
热门文章
- Flask——route
- angular 的ng-view,ngrouter
- tableview的顶部有一部分空白区域,并不是Cell的解决方法。
- Sql 数据引擎中删除用户名、密码信息
- linq 对Sum()函数的支持
- Eclipse is running in a JRE, but a JDK is required 解决方法(转)
- 浅谈Eclipse寻找JVM(JRE)的顺序机制(转)
- python模块使用案例
- Linux 夸平台 移植 Win32
- 什么是侧翼区(flanking region)和侧翼区单核苷酸多态性(Flanking SNPs)