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>
如圖:

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
iOS移動(dòng)端軟鍵盤彈起空白和滾動(dòng)穿透問題解決方案
這篇文章主要為大家介紹了iOS移動(dòng)端軟鍵盤彈起空白和滾動(dòng)穿透問題解決方案,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-07-07
iOS用AutoLayout實(shí)現(xiàn)分頁滾動(dòng)功能
這篇文章主要給大家介紹了關(guān)于iOS用AutoLayout實(shí)現(xiàn)分頁滾動(dòng)功能的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)各位iOS開發(fā)者們具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-06-06
iOS Touch ID指紋識(shí)別技術(shù)簡介
這篇文章主要為大家詳細(xì)介紹了iOS Touch ID指紋識(shí)別技術(shù),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-04-04
解析iOS開發(fā)中的FirstResponder第一響應(yīng)對(duì)象
這篇文章主要介紹了解析iOS開發(fā)中的FirstResponder第一響應(yīng)對(duì)象,包括View的FirstResponder的釋放問題,需要的朋友可以參考下2015-10-10
iOS AVCaptureSession實(shí)現(xiàn)視頻錄制功能
這篇文章主要為大家詳細(xì)介紹了iOS AVCaptureSession實(shí)現(xiàn)視頻錄制功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-05-05
iOS?實(shí)現(xiàn)類似抖音滾動(dòng)效果
這篇文章主要介紹了iOS?實(shí)現(xiàn)類似抖音滾動(dòng)效果,整體思路是我們將tableView 的contentinset設(shè)置為上面一個(gè)屏幕的高度,下面一個(gè)屏幕的高度,左右為0,這樣保證我們滾動(dòng)過去的時(shí)候2024-06-06
都是準(zhǔn)備好的內(nèi)容,需要的朋友可以參考下
iOS的UI開發(fā)中UITabBarControlle的基本使用教程
這篇文章主要介紹了iOS的UI開發(fā)中UITabBarControlle的基本使用教程,代碼基于傳統(tǒng)的Objective-C,需要的朋友可以參考下2015-12-12
Flutter?ScrollController滾動(dòng)監(jiān)聽及控制示例詳解
這篇文章主要為大家介紹了Flutter?ScrollController滾動(dòng)監(jiān)聽及控制示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-11-11

