IOS 應用跳轉 (IOS9白名單),iosios9

來源:互聯網
上載者:User

IOS 應用跳轉 (IOS9白名單),iosios9

跳轉到指定app的實現

IOS中應用的跳轉是通過URL實現的,因此在實現應用跳轉之前我們要設定一下對應的URL。

圖一(尋找配置軟體的URL)

圖二(具體配置選項)

注意:

如果IOS版本為IOS9 我們需要為app設定白名單。

實現跳轉的前提是有這個app,因此我們需要把被跳轉的app先運行,即安裝到模擬器中。

三(在info中添加)

 

代碼:

////  ViewController.m//  X////  Created by ma c on 16/4/9.//  Copyright © 2016年 bjsxt. All rights reserved.//#import "ViewController.h"@interface ViewController ()@property (weak, nonatomic) IBOutlet UIButton *button;@end@implementation ViewController- (IBAction)GoU:(id)sender {        //擷取跳轉app的URl    NSURL * url = [NSURL URLWithString:@"U://"];    //判斷手機中是否安裝了對應的app    if ([[UIApplication sharedApplication] canOpenURL:url]) {        //開啟應用程式        [[UIApplication sharedApplication]openURL:url];    }}- (void)viewDidLoad {    [super viewDidLoad];}@end

為了證明實現的是app之間的跳轉:另附兩張app的故事板

X:圖五

U:圖六

 跳轉到指定頁面的實現

前提:我們想要從X跳轉到U的朋友圈。

那麼X的代碼如下:

////  ViewController.m//  X////  Created by ma c on 16/4/9.//  Copyright © 2016年 bjsxt. All rights reserved.//#import "ViewController.h"@interface ViewController ()@property (weak, nonatomic) IBOutlet UIButton *button;@end@implementation ViewController- (IBAction)GoU:(id)sender {        //擷取跳轉app的URl    NSURL * url = [NSURL URLWithString:@"U://"];    //判斷手機中是否安裝了對應的app    if ([[UIApplication sharedApplication] canOpenURL:url]) {        //開啟應用程式        [[UIApplication sharedApplication]openURL:url];    }}- (IBAction)GoFriend:(id)sender {    //擷取跳轉朋友圈的URl    NSURL * url = [NSURL URLWithString:@"U://friend"];    //判斷手機中是否安裝了對應的app    if ([[UIApplication sharedApplication] canOpenURL:url]) {        //開啟朋友圈        [[UIApplication sharedApplication]openURL:url];    }}- (void)viewDidLoad {    [super viewDidLoad];}@end

 

我們不能僅僅對X進行設定更要對U進行設定。

對U的代碼操作在Appdeledate中。

代碼如下:

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options{        //將url轉為字串    NSString * urlString = url.absoluteString;    //判斷是通過什麼跳轉過來的    if ([urlString containsString:@"friend"]) {        NSLog(@"在這裡執行頁面跳轉即可。");    }    return YES;}

 

七如下

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.