iOS开发app间相互跳转以及appStore和系统设置

1.app间相互跳转
(1)两个项目,这里我们暂且说项目A和项目B。
(2)项目A跳转到项目B。
步骤1:打开项目B工程 找到info 目录下的URL Types,点击+号进行添加,然后设置URL schemes。
(3)将项目B的URL schemes 记录下来,以便在项目A中使用。

如图:

   



(4)回到项目A,在你需要跳转的地方写上:

</pre><p><pre name="code" class="objc"> NSURL *url = [NSURL URLWithString:@"qiyuanmall://"]; // 这里的qiyuanmall://" 你就可以替换成你在B项目的URL Schemes的值然后在后面加上@"://"
// 如果已经安装了这个应用,就跳转 
if ([[UIApplication sharedApplication] canOpenURL:url]) { [[UIApplication sharedApplication] openURL:url]; }else{ NSURL *appStore = [NSURL URLWithString:@"您app的appStore地址"];// 跳到APPStore [[UIApplication sharedApplication] openURL:appStore]; }

 (5)当然,如果你想在A跳转到B的时候,从项目A传给一些值给B,请坐如下操作: 

NSURL *url = [NSURL URLWithString:@"qiyuanmall://"];  请注意这里 eg:把@"qiyuanmall://换成[NSString stringWithFormat:@"qiyuanmall://username=%@&age=%@&address=%@", @"test123", @"100", @"上海市"];
 (6)在项目B中接受到A传的值,在APPDelegate中找到OpenURL 

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    NSString *urlStr = [url absoluteString];
    if ([urlStr hasPrefix:@"qiyuanmall://"]) {
        NSLog(@"TestAppDemo1 request params: %@", urlStr);
        urlStr = [urlStr stringByReplacingOccurrencesOfString:@"qiyuanmall://" withString:@""];
        NSArray *paramArray = [urlStr componentsSeparatedByString:@"&"];
        NSLog(@"paramArray: %@", paramArray);
        NSMutableDictionary *paramsDic = [[NSMutableDictionary alloc] initWithCapacity:0];
        for (int i = 0; i < paramArray.count; i++) {
            NSString *str = paramArray[i];
            NSArray *keyArray = [str componentsSeparatedByString:@"="];
            NSString *key = keyArray[0];
            NSString *value = keyArray[1];
            [paramsDic setObject:value forKey:key];
            NSLog(@"key:%@ ==== value:%@", key, value);
        }

    }
    return NO;
}


 2.app跳到系统设置界面 

 [[UIApplicationsharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General"]];
 
[[UIApplicationsharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General&path=Restrictions"]];
一些其他可用的参数:
List of currently known URLs in the Settings app:
prefs:root=General&path=About  //关于
prefs:root=General&path=ACCESSIBILITY//重力感应 
prefs:root=AIRPLANE_MODE//飞行模式
prefs:root=General&path=AUTOLOCK//自动锁定
prefs:root=General&path=USAGE/CELLULAR_USAGE//用量
prefs:root=Brightness//亮度调节
prefs:root=General&path=Bluetooth//蓝牙
prefs:root=General&path=DATE_AND_TIME//时间和日期
prefs:root=FACETIME//
prefs:root=General//通用
prefs:root=General&path=Keyboard//键盘
prefs:root=CASTLE//
prefs:root=CASTLE&path=STORAGE_AND_BACKUP//
prefs:root=General&path=INTERNATIONAL//
prefs:root=LOCATION_SERVICES//
prefs:root=ACCOUNT_SETTINGS//
prefs:root=MUSIC//
prefs:root=MUSIC&path=EQ//
prefs:root=MUSIC&path=VolumeLimit//
prefs:root=General&path=Network//
prefs:root=NIKE_PLUS_IPOD//
prefs:root=NOTES//
prefs:root=NOTIFICATIONS_ID//
prefs:root=Phone//
prefs:root=Photos//
prefs:root=General&path=ManagedConfigurationList//
prefs:root=General&path=Reset//
prefs:root=Sounds&path=Ringtone//
prefs:root=Safari//
prefs:root=General&path=Assistant//
prefs:root=Sounds//
prefs:root=General&path=SOFTWARE_UPDATE_LINK//
prefs:root=STORE//
prefs:root=TWITTER//
prefs:root=General&path=USAGE//
prefs:root=VIDEO//
prefs:root=General&path=Network/VPN//
prefs:root=Wallpaper//
prefs:root=WIFI//
prefs:root=INTERNET_TETHERING//


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值