iOS實(shí)現(xiàn)app間跳轉(zhuǎn)功能
本文為大家分享了iOS實(shí)現(xiàn)app間跳轉(zhuǎn)功能的具體代碼,供大家參考,具體內(nèi)容如下
我們通過系統(tǒng)的openURL方法,可以從當(dāng)前的app跳轉(zhuǎn)到其他任意app去,包括系統(tǒng)自帶的、以及我們開發(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方法通過唯一標(biāo)識(shí)來打開我們的程序
[[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)其他程序通過openURL打開該程序的時(shí)候,會(huì)觸發(fā)這個(gè)方法
// URL ,就是其他程序打開時(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í)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
iOS開發(fā)中使app獲取本機(jī)通訊錄的實(shí)現(xiàn)代碼實(shí)例
這篇文章主要介紹了iOS開發(fā)中使app獲取本機(jī)通訊錄的實(shí)現(xiàn)代碼實(shí)例,主要用到了AddressBook.framework和AddressBookUI.framework,代碼基于傳統(tǒng)的Objective-C,需要的朋友可以參考下2016-01-01
IOS 開發(fā)之ios視頻截屏的實(shí)現(xiàn)代碼
這篇文章主要介紹了IOS 開發(fā)之ios視頻截屏的實(shí)現(xiàn)代碼的相關(guān)資料,需要的朋友可以參考下2017-07-07
iOS TabBarItem設(shè)置紅點(diǎn)(未讀消息)
本文主要介紹了iOS利用TabBarItem設(shè)置紅點(diǎn)(未讀消息)的相關(guān)知識(shí)。具有很好的參考價(jià)值,下面跟著小編一起來看下吧2017-04-04
利用iOS動(dòng)畫來模擬音量振動(dòng)條的實(shí)現(xiàn)
本篇文章主要利用iOS動(dòng)畫來模擬音量振動(dòng)條的實(shí)現(xiàn)以及對(duì)CAReplicatorLayer的簡(jiǎn)單介紹,需要的朋友可以參考下2015-07-07
iOS項(xiàng)目開發(fā)--實(shí)現(xiàn)類似淘寶詳情頁(yè)面
本篇文章主要介紹了iOS實(shí)現(xiàn)類似淘寶詳情頁(yè)面,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-11-11

