01_應(yīng)用間跳轉(zhuǎn)
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options {
NSString * urlString = url.absoluteString;
NSLog(@"%@", urlString);
UINavigationController * navCtrl = ( UINavigationController * ) self.window.rootViewController ;
[navCtrl popToRootViewControllerAnimated: NO ];
// 有些巧妙,
// 從其他 客戶端 進(jìn)入后翔曲, 不退出迫像。 從多任務(wù) 窗口 調(diào)用 其他客戶端 再此 進(jìn)入, 用 UINavigationController 返回 到 上一級(jí) 窗口, 非常正常地 一步 到位瞳遍。
// 有意思闻妓。 好像 手機(jī)里的 有些應(yīng)用 有這方面 問題。
ViewController * ctrl = [navCtrl.viewControllers firstObject ];
// 不是 lastObject
NSArray * array = [urlString componentsSeparatedByString: @"?" ];
if (array.count > 1) {
NSString * sourceUrlString = array[1];
ctrl.scheme = sourceUrlString ;
}
if ( [urlString containsString: @"session" ] ) {
[ctrl performSegueWithIdentifier: @"session" sender: nil ];
} else if ( [urlString containsString: @"timeline" ] ) {
[ctrl performSegueWithIdentifier: @"timeline" sender: nil ];
}
return YES;
}
?
?
?
?
上 錯(cuò)誤
我從TestKitchen掠械, 跳轉(zhuǎn)到weixin由缆; 從weixin 上, 跳不回去猾蒂。
因?yàn)槲?沒有 傳值均唉。
我的代碼
- (IBAction)sessionAction:(id)sender {
NSURL * url = [NSURL URLWithString: @"weChat://session?" ];// ? 后面, 沒東西肚菠。
[[UIApplication sharedApplication ] openURL:url ];
}
- (IBAction)timelineAction:(id)sender {
NSURL * url = [NSURL URLWithString: @"weChat://timeline?" ];// ? 后面舔箭, 沒東西。
[[UIApplication sharedApplication ] openURL:url ];
}
老師的 代碼
//微信好友
- (IBAction)sessionAction:(id)sender {
NSURL *url = [NSURL URLWithString:@"wechat://session?kitchen"];
[[UIApplication sharedApplication] openURL:url];
}
//微信朋友圈
- (IBAction)timelineAction:(id)sender {
NSURL *url = [NSURL URLWithString:@"wechat://timeline?kitchen"];
[[UIApplication sharedApplication] openURL:url];
}