iOS實(shí)現(xiàn)app間跳轉(zhuǎn)功能
本文為大家分享了iOS實(shí)現(xiàn)app間跳轉(zhuǎn)功能的具體代碼,供大家參考,具體內(nèi)容如下
我們通過(guò)系統(tǒng)的openURL方法,可以從當(dāng)前的app跳轉(zhuǎn)到其他任意app去,包括系統(tǒng)自帶的、以及我們開(kāi)發(fā)的app。
本文模擬A app跳轉(zhuǎn)到 B app
A app代碼:
// A app // ViewController.m // 程序跳轉(zhuǎn) // // Created by hhg on 15/10/23. // Copyright (c) 2015年 hhg. All rights reserved. // #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { // 為我們的程序設(shè)置一個(gè)唯一的標(biāo)識(shí),那么其他軟件就可以使用openURL方法通過(guò)唯一標(biāo)識(shí)來(lái)打開(kāi)我們的程序 [[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"zapp:"]]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } @end
B app代碼:
// B app // AppDelegate.m // MyApp // // Created by hhg on 15/10/23. // Copyright (c) 2015年 hhg. All rights reserved. // #import "AppDelegate.h" @interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { return YES; } // 當(dāng)其他程序通過(guò)openURL打開(kāi)該程序的時(shí)候,會(huì)觸發(fā)這個(gè)方法 // URL ,就是其他程序打開(kāi)時(shí)候的URL - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"跳轉(zhuǎn)成功!" delegate:nil cancelButtonTitle:@"確定" otherButtonTitles: nil]; [alertView show]; return YES; } - (void)applicationWillResignActive:(UIApplication *)application { } - (void)applicationDidEnterBackground:(UIApplication *)application { } - (void)applicationWillEnterForeground:(UIApplication *)application { } - (void)applicationDidBecomeActive:(UIApplication *)application { } - (void)applicationWillTerminate:(UIApplication *)application { } @end
B app 在info.plist 文件里面需要設(shè)置:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <array> <dict> <key>CFBundleURLName</key> <string></string> <key>CFBundleURLSchemes</key> <array> <string>zapp</string> </array> </dict> </array> </plist>
如圖:
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- iOS整個(gè)APP實(shí)現(xiàn)灰色主題的示例代碼
- iOS APP實(shí)現(xiàn)微信H5支付示例總結(jié)
- iOS APP 多服務(wù)器環(huán)境分離的方法
- iOS App使用GCD導(dǎo)致的卡頓現(xiàn)象及解決方法
- iOS中在APP內(nèi)加入AppStore評(píng)分功能的實(shí)現(xiàn)方法
- iOS 11 AppIcon不顯示問(wèn)題小結(jié)
- iOS app 右滑返回操作的兩種方法
- iOS開(kāi)發(fā)中以application/json上傳文件實(shí)例詳解
- 淺談IOS如何對(duì)app進(jìn)行安全加固
相關(guān)文章
iOS開(kāi)發(fā)中使app獲取本機(jī)通訊錄的實(shí)現(xiàn)代碼實(shí)例
這篇文章主要介紹了iOS開(kāi)發(fā)中使app獲取本機(jī)通訊錄的實(shí)現(xiàn)代碼實(shí)例,主要用到了AddressBook.framework和AddressBookUI.framework,代碼基于傳統(tǒng)的Objective-C,需要的朋友可以參考下2016-01-01IOS 開(kāi)發(fā)之ios視頻截屏的實(shí)現(xiàn)代碼
這篇文章主要介紹了IOS 開(kāi)發(fā)之ios視頻截屏的實(shí)現(xiàn)代碼的相關(guān)資料,需要的朋友可以參考下2017-07-07iOS TabBarItem設(shè)置紅點(diǎn)(未讀消息)
本文主要介紹了iOS利用TabBarItem設(shè)置紅點(diǎn)(未讀消息)的相關(guān)知識(shí)。具有很好的參考價(jià)值,下面跟著小編一起來(lái)看下吧2017-04-04利用iOS動(dòng)畫來(lái)模擬音量振動(dòng)條的實(shí)現(xiàn)
本篇文章主要利用iOS動(dòng)畫來(lái)模擬音量振動(dòng)條的實(shí)現(xiàn)以及對(duì)CAReplicatorLayer的簡(jiǎn)單介紹,需要的朋友可以參考下2015-07-07iOS項(xiàng)目開(kāi)發(fā)--實(shí)現(xiàn)類似淘寶詳情頁(yè)面
本篇文章主要介紹了iOS實(shí)現(xiàn)類似淘寶詳情頁(yè)面,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-11-11