2017-02-23 39 views
0

https://www.google.co.in/如何在目標c中打開https鏈接?

https://en-gb.facebook.com/login/

我可以在上面的鏈接打開成功......但是下面鏈接在web視圖爲什麼不開?如何解決這個問題呢?

https://itunes.apple.com/in/developer/whatsapp-inc/id310634000?mt=8&uo=2

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view. 

    UIWebView *webView = [[UIWebView alloc]init]; 
    webView.frame = self.view.frame; 
    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.urlString]]]; 
    [self.view addSubview:webView]; 
    NSLog(@"%@", self.urlString); 
    // https://itunes.apple.com/in/developer/whatsapp-inc/id310634000?mt=8&uo=2 
} 

這self.urlString來自服務器...

+0

://而不使用https:從服務器// –

+0

其實這是網上的數據來(Web服務的概念),如何我可以做 – Marking

+0

我試過它不工作.... – Marking

回答

0

在ViewController.h文件中創建一個出口

@property (strong, nonatomic) IBOutlet UIWebView *webview; 

在ViewController.m文件viewDidLoad

_webview.delegate = self; 

[_webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://%@",URLSTRING FROM SEVER]]]]; 
+0

這是我的字符串來自服務器... https: //itunes.apple.com/in/developer/whatsapp-inc/id310634000?mt=8&uo=2 – Marking

+0

已經嘗試將https://更改爲http://,但重定向了..... – Marking

1

從這個Link

也許更好的用戶體驗itunes鏈接不UIWebView iTunes的內容不會對手機的「iTunes的預覽」網頁打開 - iOS設備自動識別itunes.apple.com鏈接,打開商店。

所以,如果你想打開itunes鏈接,你應該使用SKStoreProductViewController。它會在您的應用中打開您的itunes項目。 以下鏈接使用ITMS使用SKStoreProductViewController

How to links to apps to app store

Documentation

0
NSString *fullURL = @"https://itunes.apple.com/in/developer/whatsapp-inc/id310634000?mt=8&uo=2"; 
NSURL *url = [NSURL URLWithString:fullURL]; 
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; 
[_viewWeb loadRequest:requestObj];