你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> iOS 第三方應用調用safari

iOS 第三方應用調用safari

編輯:IOS開發綜合

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

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

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved