iOS 第三方應用調用safari – iPhone手機開發技術文章 iPhone軟體開發教學課程

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

如果當webView內部打開鏈接時用safari
當然這必須委托給自己
webView.delegate=self;
也當然要加 www.aiwalls.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;
}

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。