en

hi, it seems you are using microsoft internet explorer. it doesn't match web standard and causes problems browsing this site. please please please use mozilla firefox or google chrome instead. thank you!

zh

哦哦!您正在使用Internet Explorer 瀏覽器,它與我們的網頁標準並不相容,可能會導致畫面顯示不正常。
請改用 Mozilla Firefox 或者 Google Chrome 才能正常瀏覽本網站,謝謝!

1.27.2011

使用 UIApplication 呼叫 iOS 內建 App Store 或 iTunes

 

如果你使用模擬器 Simulator 進行編譯與執行,在點擊按鈕時並不會出現 App Store 應用程式,因為 Simulator 並沒有內建 App Store 應用程式,如要測試此功能請在 Device 模式下,其程式碼如下。

//從textFieldf取得位址
NSString *url = textField.text;

//重新格式化tel為UTF8
url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

NSString *urlString = [NSString stringWithFormat:@"http://%@", url];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];

其實開啟內建 App Store 的方法與開啟內建 Safari 瀏覽器相當雷同,系統判定頁面位置如果是需要連線至 App Store 或是 iTunes 就會呼叫其內建應用程式並開啟。





沒有留言:

張貼留言