1.兩個 App之間的跳轉
場景:App1通過點擊按鈕跳轉到App2
首先在App2中選擇項目App2 -> TARGETS -> Info -> URL Types -> URL Schemes,設置App-2的URL Schemes為App2

然后在App1中實現(xiàn)跳轉邏輯
- (IBAction)jumpToApp2:(id)sender {
// 1.獲取應用程序App2的URL Scheme
NSURL *app2Url = [NSURL URLWithString:@"App2://"];
// 2.判斷手機中是否安裝了對應程序
if ([[UIApplication sharedApplication] canOpenURL:app2Url]) {
// 3. 打開應用程序App2
[[UIApplication sharedApplication] openURL:app2Url];
} else {
NSLog(@"沒有安裝App2");
}
}
2.通過網頁跳轉App
場景:通過App分享出去的某個網頁,點擊網頁上的某個按鈕可以打開App
首先和上面一樣設置App的URL Schemes,
然后在網頁中添加
<body>
<a id="openApp">打開app</a>
<script type="text/javascript">
document.getElementById('openApp').onclick = function(e){
var ifr = document.createElement('iframe');
ifr.src = 'App2://showMessage?https://www.baidu.com';
ifr.style.display = 'none';
document.body.appendChild(ifr);
window.setTimeout(function(){
document.body.removeChild(ifr);
},3000)
};
</script>
</body>
3.將App獲取到的文件通過其他App打開
場景:在App1中下載的pdf文件(除了圖片和視頻的其他文件),通過QQ或者微信發(fā)給好友.

//先將下載到的文件放在本地沙盒
//然后將下面代碼放在按鈕點擊方法里
UIDocumentInteractionController *documentController = [UIDocumentInteractionController interactionControllerWithURL:[[NSBundle mainBundle] URLForResource:@"MyFile" withExtension:@"pdf"]];
[documentController presentOpenInMenuFromRect:self.view.bounds inView:self.view animated:YES];