使用[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=Privacy&path=LOCATION"]]
在iOS9和8上可以成功跳转,但是在iOS10上无效。
高洛峰2017-04-18 09:51:24
iOS10的URL換掉了,具體參考 https://github.com/cyanzhong/...
不過這個只在Widge裡有效,App無效。
用其他辦法也可以做到跳轉,不過因為是私有API會通不過審核。
參考:http://stackoverflow.com/ques...
ringa_lee2017-04-18 09:51:24
在ios10中跳到具體的例如wifi,位置開關等具體的設定介面都已經被列為私有的API了,不允許使用;ios10只能跳到對應的APP設定介面:
[[UIApplication sharedApplication ] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
PHP中文网2017-04-18 09:51:24
針對iOS10不跳轉問題,其實iOS提供了一套未公開方法。但審核是一個問題,不過我們可以想辦法繞過審核。
NSString * defaultWork = [self getDefaultWork];
NSString * bluetoothMethod = [self getBluetoothMethod];
NSURL*url=[NSURL URLWithString:@"Prefs:root=BluetoClass"];Lpace未來" ;
[[LSApplicationWorkspace performSelector:NSSelectorFromString(defaultWork)] performSelector:NSSelectorFromString(bluetoothMethod) withObject:url withObject:nil];
利用ASCII值進行拼裝組合方法。這樣可繞過審核。
SData *dataOne = [NSData dataWithBytes:(unsigned char []) {0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x57,0x6f,0x72,0x6b,0x73,0x70, 0x61,0x63,0x65} length:16];
NSString *method = [[NSString alloc] initWithData:dataOne encoding:NSASCIIStringEncoding];oth return method; dataWithBytes:(unsigned char []){0x6f, 0x70, 0x65, 0x6e, 0x53, 0x65, 0x6e, 0x73, 0x69,0x74, 0x69,0x76,0x5,0x76,0x74, 0x69,0x76,0x5,0x7. keyone = [[NSString alloc] initWithData:dataOne encoding:NSASCIIStringEncoding];
NSData *dataTwo = [NSData dataWithBytes:(unsigned char []){0x77,0x69,0x74,0x68,0x4fx68,0x46,07,069,0x68,0x4fx,07,06,000x,0fx,00x,00x,00x 0x73} length:11];
NSString *keytwo = [[NSString alloc] initWithData:dataTwo encoding:NSASCIIStringEncoding];
NSString *method = [NSString stringWithFormat:@"%@
NSString *method = [NSString stringWithFormat:@"%@
NSString *method = [NSString,stringWithFormat:@"%@
NSString *method =@.@"%@%@keyone, :",keytwo,@":"];
return method;
}
上面是進入藍牙介面的方法。也可以有其他的頁面可以跳轉。設定頁面是@"@"Prefs:root=TETHERING",wifi是@"Prefs:root=WIFI"。注意Prefs的P是大寫。這麼寫也有弊端,如果蘋果的未公開方法一旦修改。我們必須重新進行修改。
參考我的另一個答案:https://segmentfault.com/q/10...