iOS 10 更新以后,发现以前跳转系统应用的方法无效了。(已解决:参考 https://github.com/sushushu/i...)
-(void)toWIFI {
NSURL *url = [NSURL URLWithString:@"prefs:root=WIFI"];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url]; // iOS 9 的跳转
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];// iOS 10 的跳转方式
}
}
iOS 9的时候[[UIApplication sharedApplication] openURL:url];
这个方法正常跳转,到了iOS 10的时候这个方法就不能用了。官方API如下:
- (BOOL)openURL:(NSURL*)url NS_DEPRECATED_IOS(2_0, 10_0, "Please use openURL:options:completionHandler: instead") NS_EXTENSION_UNAVAILABLE_IOS("");
- (BOOL)canOpenURL:(NSURL *)url NS_AVAILABLE_IOS(3_0);
// Options are specified in the section below for openURL options. An empty options dictionary will result in the same
// behavior as the older openURL call, aside from the fact that this is asynchronous and calls the completion handler rather
// than returning a result.
// The completion handler is called on the main queue.
- (void)openURL:(NSURL*)url options:(NSDictionary<NSString *, id> *)options completionHandler:(void (^ __nullable)(BOOL success))completion NS_AVAILABLE_IOS(10_0) NS_EXTENSION_UNAVAILABLE_IOS("");
请问我该如何使用新的API- (void)openURL:(NSURL*)url options:(NSDictionary<NSString *, id> *)options completionHandler:(void (^ __nullable)(BOOL success))completion NS_AVAILABLE_IOS(10_0) NS_EXTENSION_UNAVAILABLE_IOS("");
或者说这个options我该传什么进去(经测试,传空字典是没有用的)?
万分感谢。
放弃吧,iOS 10 不允许跳转到任何系统设置。