码迷,mamicode.com
首页 > 移动开发 > 详细

iOS程序中打开其他程序的方法

时间:2014-08-05 19:42:40      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:http   java   os   io   ar   type   ios   app   

1.1 如果被打开程序不是自己的,则要找到被打开App的URL Schemes。
http://jbguide.me/2012/09/12/how-to-find-url-schemes%EF%BC%9F/

1.2 如果被打开程序是自己写的,那么写程序时要实现
1) appname-info.plist里增加

<key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>CalledApp</string>
            </array>
            <key>CFBundleURLName</key>
            <string>com.yourcompany.appName</string>
        </dict>
    </array>

2) 如需参数 实现UIApplication delegate

  • (BOOL)application:(UIApplication )application openURL:(NSURL )url
    sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    if ([[url scheme] isEqualToString:@“CalledApp”]) {
    //根据路径解析参数
    ....
    return YES;
    }
    return NO;
    }

2 打开其他程序APP完成以下操作

if(YES == [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@“CalledApp://com.yourcompany.appName”]]){

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"CalledApp://com.yourcompany.appName"]]
//其他参数通过路径送入

}

iOS程序中打开其他程序的方法,布布扣,bubuko.com

iOS程序中打开其他程序的方法

标签:http   java   os   io   ar   type   ios   app   

原文地址:http://my.oschina.net/bygreencn/blog/298209

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!