2009-07-07 17 views
22

मुझे पता है कि एक ऐप इस कोड का उपयोग करके अन्य ऐप्स लॉन्च कर सकता है: [[UIApplication sharedApplication] openURL:appUrl];। और मैं सफारी और मेल खोलने के लिए यूआरएल की योजना जानता हूं, लेकिन मैंने कुछ खोज की और सेटिंग्स.एप की योजना के बारे में कुछ भी नहीं मिला।क्या openURL का उपयोग कर सेटिंग ऐप खोलना संभव है?

+1

के संभावित डुप्लिकेट [सेटिंग एप्लिकेशन खोलना एक और ऐप से] (http://stackoverflow.com/questions/5655674/opening-the-settings-app-from-another-app) – Flexo

+0

मुझे लगता है [यह सवाल] (http://stackoverflow.com/questions/377102/कैसे करते हैं-ए-खुली-सेटिंग-आवेदन-fr ओम-मेरा-एप्लिकेशन) इसका उत्तर देता है। –

+1

इस उत्तर को जांचें: http://stackoverflow.com/questions/28152526/how-do-i-open-phone-settings-when-a-button-is-clicked-ios/34024467#34024467 –

उत्तर

16

आप इसे आईओएस संस्करण 5.0 - 5.0.1 में उपयोग कर सकते हैं। इसके बाद आईओएस 5.1 में इसे हटा दिया गया था।

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs://"]]; 
+24

अब आईओएस में काम नहीं करता है 5.1। – mrueg

+0

आईओएस 5.1 के लिए कुछ भी? –

31

आप सेटिंग्स को खोलने के प्रोग्राम के रूप में यह कोशिश एप्लिकेशन ही कर सकते हैं (केवल से iOS8 के बाद काम करता है)।

आप स्विफ्ट उपयोग कर रहे हैं:

UIApplication.sharedApplication().openURL(NSURL(string: UIApplicationOpenSettingsURLString)) 

आप ऑब्जेक्टिव-सी

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]]; 

उपयोग कर रहे हैं अन्य के संस्करणों के लिए (कम से कम iOS8) ने अपने प्रोग्राम के खुले सेटिंग ऐप के लिए संभव नहीं ।

+0

बड़े अंगूठे ऊपर! यह भी खूब रही। मैंने आईओएस 7.1 पर परीक्षण किया और आईओएस 8 चलाते समय ऐप को क्रैश कर दिया, यह आपको ऐप्पल सेटिंग्स –

+7

पर ले जाता है, क्या सामान्य सेटिंग्स ऐप (टॉप-लेवल) पर खुलने का कोई तरीका है, अपनी ऐप सेटिंग्स पर ड्रिल नहीं किया गया है ? – zonabi

3

उद्घाटन सेटिंग्स प्रोग्राम के रूप में एप्लिकेशन तभी संभव है आईओएस 8. से तो, से निम्नलिखित कोड का उपयोग http://code-ios.blogspot.in/2014/10/opening-settings-app-from-another-app.html

if([CLLocationManager locationServicesEnabled]&& 
    [CLLocationManager authorizationStatus] != kCLAuthorizationStatusDenied) 
{ 
    //...Location service is enabled 
} 
else 
{ 
    if([[[UIDevice currentDevice] systemVersion] floatValue]<8.0) 
    { 
    UIAlertView* curr1=[[UIAlertView alloc] initWithTitle:@"This app does not have access to Location service" message:@"You can enable access in Settings->Privacy->Location->Location Services" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; 
    [curr1 show]; 
    } 
    else 
    { 
     UIAlertView* curr2=[[UIAlertView alloc] initWithTitle:@"This app does not have access to Location service" message:@"You can enable access in Settings->Privacy->Location->Location Services" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Settings", nil]; 
     curr2.tag=121; 
     [curr2 show]; 
    } 
} 

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
NSLog(@"buttonIndex:%d",buttonIndex); 

    if (alertView.tag == 121 && buttonIndex == 1) 
{ 
    //code for opening settings app in iOS 8 
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]]; 
} 
} 
+0

हालांकि उपयोगकर्ता पर इसका अधिक नियंत्रण नहीं है, फिर भी आप [CLLocationManager प्रमाणीकरण स्थिति] के लिए एक चेक जोड़ना चाहेंगे! = KCLAuthorizationStatusRestricted –

0

स्विफ्ट 4 संस्करण:

if let url = URL(string: UIApplicationOpenSettingsURLString) { 
    UIApplication.shared.openURL(url) 
} 
संबंधित मुद्दे