当前位置:编程学习 > wap >>

iOS 第三方应用调用safari

 
就用这就能打开safari;
NSURL* url = [[ NSURL alloc ] initWithString :@"http://www.baidu.com"];
[[UIApplication sharedApplication ] openURL: [url autorelease ]];

如果当webView内部打开链接时用safari
当然这必须委托给自己
webView.delegate=self;
也当然要加 www.zzzyk.com
<UIWebViewDelegate>
这样就会自动调用该方法了
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType;
{
    NSURL *requestURL =[ [ request URL ] retain ];
    if ( ( [ [ requestURL scheme ] isEqualToString: @"http" ] || [ [ requestURL scheme ] isEqualToString: @"https" ] || [ [ requestURL scheme ] isEqualToString: @"mailto" ])
        && ( navigationType == UIWebViewNavigationTypeLinkClicked ) ) {
        return ![ [ UIApplication sharedApplication ] openURL: [ requestURL autorelease ] ];
    }
    [ requestURL release ];
    return YES;
}

补充:移动开发 , IOS ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,