如何从应用程序中启动设置包?

时间:2021-10-02 20:59:47

I am working on adding in a settings bundle for my application as a cheap way of getting a GUI on my preferences. Is it possible to launch this from a button in my application or will my users always have to access it manually via the built in settings application?

我正在为我的应用程序添加一个设置包,作为在我的首选项上获得GUI的廉价方法。是否可以从我的应用程序中的一个按钮启动它,或者我的用户总是需要通过在设置应用程序中构建的方式手动访问它?

6 个解决方案

#1


9  

They may have to go to the settings application, depending on how you do it.

他们可能需要进入设置应用程序,这取决于你怎么做。

See this document, the Applications Preferences section. Here's the relevant section from the introduction:

请参阅本文档“应用程序首选项”一节。以下是引言部分的相关内容:

Adding your application preferences to the Settings application is most appropriate for productivity-style applications and in situations where you have preference values that are typically configured once and then rarely changed. For example, the Mail application uses these preferences to store the user’s account information and message-checking settings. Because the Settings application has support for displaying preferences hierarchically, manipulating your preferences from the Settings application is also more appropriate when you have a large number of preferences. Providing the same set of preferences in your application might require too many screens and might cause confusion for the user.

将您的应用程序首选项添加到设置应用程序是最适合于生产力风格的应用程序,并且在您具有通常配置一次然后很少更改的首选项值的情况下。例如,邮件应用程序使用这些首选项来存储用户的帐户信息和消息检查设置。因为设置应用程序支持分层显示首选项,所以当您有大量的首选项时,从设置应用程序操纵您的首选项也更合适。在应用程序中提供相同的一组首选项可能需要太多的屏幕,可能会给用户带来混乱。

When your application has only a few options or has options that the user might want to change regularly, you should think carefully about whether the Settings application is the right place for them. For instance, utility applications provide custom configuration options on the back of their main view. A special control on the view flips it over to display the options and another control flips the view back. For simple applications, this type of behavior provides immediate access to the application’s options and is much more convenient for the user than going to Settings.

当应用程序只有几个选项或用户可能希望定期更改的选项时,您应该仔细考虑设置应用程序是否适合它们。例如,实用程序在主视图的后面提供自定义配置选项。在视图上的一个特殊控件翻转它以显示选项,而另一个控件翻转视图。对于简单的应用程序,这种类型的行为提供了对应用程序选项的直接访问,而且对用户来说比进入设置要方便得多。

Update

更新

The link has expired. This is a similar document on Settings bundles.

链接已经过期。这是设置包上的类似文档。

#2


5  

For iOs5 you can open settings directly:

对于iOs5,可以直接打开设置:

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

[[UIApplication sharedApplication]openURL:(NSURL URLWithString:@ "首选项:/ / "]];

#3


4  

Answered my own question: You can indeed use the NSUserDefaults for saving your own applications preferences without having to integrate with the system settings.

回答了我自己的问题:您确实可以使用NSUserDefaults来保存自己的应用程序首选项,而不必与系统设置集成。

For example, my app is a Utility app with a small UI for a couple of settings on the FlipSide (the view the user gets to when pressing the "i" button).

例如,我的应用程序是一个实用程序,它有一个小的用户界面,可以在FlipSide上设置几个设置(当用户按下“i”按钮时,用户可以看到它)。

Note that I found this information from two sources.

注意,我从两个来源找到了这些信息。

  1. In a great series of reports from iPhone BootCamp, Scott Leberknight mentions in passing that he was taught that an applications user-defaults may or may not integrate in the settings app.

    在iPhone BootCamp发布的一系列报告中,Scott Leberknight顺便提到,他被告知,应用程序的用户默认值可能会在设置应用程序中集成,也可能不会。

  2. The Sample code from the iphone official developer page for the BubbleLevel uses preferences for storing the calibration of the level (which is set on the flipside view)

    BubbleLevel的iphone官方开发页面的示例代码使用首选项来存储级别的校准(在flipside视图中设置)

Here are the methods in LevelAppDelegate.m that load the preference when the application starts, and saves it when it terminates:

这是LevelAppDelegate中的方法。m在应用程序启动时加载首选项,在终止时保存:

// Invoked after the application has been launched and initialized but before it has received its first event.
- (void)applicationDidFinishLaunching:(UIApplication *)application {
    // Set up the level view controller
    levelViewController = [[LevelViewController alloc] init];
    [window addSubview:levelViewController.view];

    // Restore calibration for device
    float restoredOffset = [[NSUserDefaults standardUserDefaults] floatForKey:BubbleLevelCalibrationOffsetKey];
    levelViewController.calibrationOffset = restoredOffset;
}


// Invoked immediately before the application terminates.
- (void)applicationWillTerminate:(UIApplication *)application {
    float calibrationOffset = levelViewController.calibrationOffset;
    NSNumber *offset = [NSNumber numberWithFloat:calibrationOffset];
    [[NSUserDefaults standardUserDefaults] setObject:offset forKey:BubbleLevelCalibrationOffsetKey];
}

I guess, however, that the proper answer to the original question is:

然而,我想,对最初问题的正确答案是:

  1. No - you can't launch the settings UI from your own app (I haven't seen any way to do this - could be wrong I guess - but I'm pretty sure that even if you could launch Settings from your app, say the way a URL can be used to launch Safari - you wouldn't be able to return to your app from the Settings app, which would defeat the purpose).

    不——你不能从自己的启动设置UI应用程序(我还没有看到任何的方法——我猜可能是错的,但我敢肯定,即使你可以从你的应用程序启动设置,说一个URL的方式可以用来发射Safari——你不能回到你的应用从设置应用程序,这将失败的目的)。

  2. For preference-level persistence (as opposed to app data persisted in documents, database or cache) you have 2 choices i) use the system Settings app for your editing ii) create your own controls in your app

    对于首选级持久性(与保存在文档、数据库或缓存中的应用程序数据相反),您有两个选项i)使用系统设置应用程序进行编辑ii)在应用程序中创建您自己的控件

In either case you can use the NSUserDefaults for the actual persistence.

在这两种情况下,您都可以使用NSUserDefaults来实现实际的持久性。

#4


2  

I'm not aware of any way to launch Settings.app from your app. However, why not integrate the settings right in your app? You can use InAppSettingsKit to do that very easily.

我不知道如何启动设置。app中的app,为什么不把设置整合到app中呢?您可以使用InAppSettingsKit来很容易地做到这一点。

#5


1  

No, you can't--they'll have to exit your app and launch settings. It's a pain, and as stated above, a design decision you'll have to make.

不,你不能——他们必须退出你的应用并启动设置。这是一种痛苦,正如上面所述,这是你必须做出的设计决定。

#6


1  

I just saw the Aka-aki app take me directly to the Settings app's push notification screen. It did this the first time I launched it. So it must be possible. :)

我刚看到Aka-aki应用程序直接把我带到设置app的推送通知屏幕。这是我第一次发布它。所以这一定是可能的。:)

#1


9  

They may have to go to the settings application, depending on how you do it.

他们可能需要进入设置应用程序,这取决于你怎么做。

See this document, the Applications Preferences section. Here's the relevant section from the introduction:

请参阅本文档“应用程序首选项”一节。以下是引言部分的相关内容:

Adding your application preferences to the Settings application is most appropriate for productivity-style applications and in situations where you have preference values that are typically configured once and then rarely changed. For example, the Mail application uses these preferences to store the user’s account information and message-checking settings. Because the Settings application has support for displaying preferences hierarchically, manipulating your preferences from the Settings application is also more appropriate when you have a large number of preferences. Providing the same set of preferences in your application might require too many screens and might cause confusion for the user.

将您的应用程序首选项添加到设置应用程序是最适合于生产力风格的应用程序,并且在您具有通常配置一次然后很少更改的首选项值的情况下。例如,邮件应用程序使用这些首选项来存储用户的帐户信息和消息检查设置。因为设置应用程序支持分层显示首选项,所以当您有大量的首选项时,从设置应用程序操纵您的首选项也更合适。在应用程序中提供相同的一组首选项可能需要太多的屏幕,可能会给用户带来混乱。

When your application has only a few options or has options that the user might want to change regularly, you should think carefully about whether the Settings application is the right place for them. For instance, utility applications provide custom configuration options on the back of their main view. A special control on the view flips it over to display the options and another control flips the view back. For simple applications, this type of behavior provides immediate access to the application’s options and is much more convenient for the user than going to Settings.

当应用程序只有几个选项或用户可能希望定期更改的选项时,您应该仔细考虑设置应用程序是否适合它们。例如,实用程序在主视图的后面提供自定义配置选项。在视图上的一个特殊控件翻转它以显示选项,而另一个控件翻转视图。对于简单的应用程序,这种类型的行为提供了对应用程序选项的直接访问,而且对用户来说比进入设置要方便得多。

Update

更新

The link has expired. This is a similar document on Settings bundles.

链接已经过期。这是设置包上的类似文档。

#2


5  

For iOs5 you can open settings directly:

对于iOs5,可以直接打开设置:

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

[[UIApplication sharedApplication]openURL:(NSURL URLWithString:@ "首选项:/ / "]];

#3


4  

Answered my own question: You can indeed use the NSUserDefaults for saving your own applications preferences without having to integrate with the system settings.

回答了我自己的问题:您确实可以使用NSUserDefaults来保存自己的应用程序首选项,而不必与系统设置集成。

For example, my app is a Utility app with a small UI for a couple of settings on the FlipSide (the view the user gets to when pressing the "i" button).

例如,我的应用程序是一个实用程序,它有一个小的用户界面,可以在FlipSide上设置几个设置(当用户按下“i”按钮时,用户可以看到它)。

Note that I found this information from two sources.

注意,我从两个来源找到了这些信息。

  1. In a great series of reports from iPhone BootCamp, Scott Leberknight mentions in passing that he was taught that an applications user-defaults may or may not integrate in the settings app.

    在iPhone BootCamp发布的一系列报告中,Scott Leberknight顺便提到,他被告知,应用程序的用户默认值可能会在设置应用程序中集成,也可能不会。

  2. The Sample code from the iphone official developer page for the BubbleLevel uses preferences for storing the calibration of the level (which is set on the flipside view)

    BubbleLevel的iphone官方开发页面的示例代码使用首选项来存储级别的校准(在flipside视图中设置)

Here are the methods in LevelAppDelegate.m that load the preference when the application starts, and saves it when it terminates:

这是LevelAppDelegate中的方法。m在应用程序启动时加载首选项,在终止时保存:

// Invoked after the application has been launched and initialized but before it has received its first event.
- (void)applicationDidFinishLaunching:(UIApplication *)application {
    // Set up the level view controller
    levelViewController = [[LevelViewController alloc] init];
    [window addSubview:levelViewController.view];

    // Restore calibration for device
    float restoredOffset = [[NSUserDefaults standardUserDefaults] floatForKey:BubbleLevelCalibrationOffsetKey];
    levelViewController.calibrationOffset = restoredOffset;
}


// Invoked immediately before the application terminates.
- (void)applicationWillTerminate:(UIApplication *)application {
    float calibrationOffset = levelViewController.calibrationOffset;
    NSNumber *offset = [NSNumber numberWithFloat:calibrationOffset];
    [[NSUserDefaults standardUserDefaults] setObject:offset forKey:BubbleLevelCalibrationOffsetKey];
}

I guess, however, that the proper answer to the original question is:

然而,我想,对最初问题的正确答案是:

  1. No - you can't launch the settings UI from your own app (I haven't seen any way to do this - could be wrong I guess - but I'm pretty sure that even if you could launch Settings from your app, say the way a URL can be used to launch Safari - you wouldn't be able to return to your app from the Settings app, which would defeat the purpose).

    不——你不能从自己的启动设置UI应用程序(我还没有看到任何的方法——我猜可能是错的,但我敢肯定,即使你可以从你的应用程序启动设置,说一个URL的方式可以用来发射Safari——你不能回到你的应用从设置应用程序,这将失败的目的)。

  2. For preference-level persistence (as opposed to app data persisted in documents, database or cache) you have 2 choices i) use the system Settings app for your editing ii) create your own controls in your app

    对于首选级持久性(与保存在文档、数据库或缓存中的应用程序数据相反),您有两个选项i)使用系统设置应用程序进行编辑ii)在应用程序中创建您自己的控件

In either case you can use the NSUserDefaults for the actual persistence.

在这两种情况下,您都可以使用NSUserDefaults来实现实际的持久性。

#4


2  

I'm not aware of any way to launch Settings.app from your app. However, why not integrate the settings right in your app? You can use InAppSettingsKit to do that very easily.

我不知道如何启动设置。app中的app,为什么不把设置整合到app中呢?您可以使用InAppSettingsKit来很容易地做到这一点。

#5


1  

No, you can't--they'll have to exit your app and launch settings. It's a pain, and as stated above, a design decision you'll have to make.

不,你不能——他们必须退出你的应用并启动设置。这是一种痛苦,正如上面所述,这是你必须做出的设计决定。

#6


1  

I just saw the Aka-aki app take me directly to the Settings app's push notification screen. It did this the first time I launched it. So it must be possible. :)

我刚看到Aka-aki应用程序直接把我带到设置app的推送通知屏幕。这是我第一次发布它。所以这一定是可能的。:)