iOS --- 通过UIApplication的openURL来实现APP之间的相互跳转
2015-09-07 09:37
459 查看
iOS设备中, APP之间的相互跳转主要是通过UIApplication的openURL来实现的.
以Instagram(未提供SDK)为例:
即:
使用[[UIApplication sharedApplication] canOpenURL:instagramURL];来判断是否已安装该APP,
使用[[UIApplication sharedApplication] openURL:fansPageURL];来打开该APP, 若未安装, 则默认在safari中打开相应页面.
以Instagram(未提供SDK)为例:
// // ViewController.m #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; NSString *username = @"icetime017"; [self openUserPage:username]; } - (BOOL)isInstagramInstalled { NSURL *instagramURL = [NSURL URLWithString:@"instagram://location?id=1"]; return [[UIApplication sharedApplication] canOpenURL:instagramURL]; } - (void)openUserPage:(NSString *)username { NSURL *fansPageURL; if ([self isInstagramInstalled]) { fansPageURL = [NSURL URLWithString:[NSString stringWithFormat:@"instagram://user?username=%@", username]]; } else { fansPageURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://instagram.com/%@", username]]; } [[UIApplication sharedApplication] openURL:fansPageURL]; } @end
即:
使用[[UIApplication sharedApplication] canOpenURL:instagramURL];来判断是否已安装该APP,
使用[[UIApplication sharedApplication] openURL:fansPageURL];来打开该APP, 若未安装, 则默认在safari中打开相应页面.
相关文章推荐
- Type 'Insus.NET.PictureObject' in Assembly 'App_Code, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.
- 【Android】2015.09.04 第一行代码 Day4 Count:6
- IOS手势
- android权限管理, API劫持, xposed, xprivacy
- 自适应reset.js布局 用于手机端页面编写
- android studio gradle project sync failed,和android studio Error:Unable to start the daemon process问题
- iOS:记一次Mac OS X 测试版(OS X EL Capitan) APP发布过程
- ios视频和音频的合成
- iOS:KVO的概述与使用
- Android Weight 使用 详解
- android spinner 调用onItemSelectedListener的思考
- 【Unity】Update()和FixedUpdate()
- Android 源码下载编译 FAQ
- Objective-C 与 Runtime:为什么是这样?
- Qt的前景如何?Qt for Android 好吗?
- iOS NSUserDefaults的使用
- utils object doesn,t exists中毒后,就删除了.JS文件后台就出现了前面的英文。请问怎么解决
- 寒哥教你学 iOS - 经验漫谈
- Android提供的LruCache类简介
- App 控件定位讲解 (hierarchyviewer 篇)