简体   繁体   English

从Settings.app中呈现一个模式视图控制器

[英]Presenting a modal view controller from within Settings.app

I decided to use InAppSettingsKit for my app. 我决定为我的应用程序使用InAppSettingsKit。 However, certain settings require the user to use the audio input for custom setting. 但是,某些设置要求用户使用音频输入进行自定义设置。 I was wondering whether there is a way of presenting a modal view controller from within Settings.bundle - getting the parent view controller that presents Settings.app to sense that a button/setting was changed and launch another view controller on top of this one to pick the new setting from audio input and pass it on to the setting.bundle? 我想知道是否有一种方法可以从Settings.bundle中显示模式视图控制器-获取显示Settings.app的父视图控制器以感知按钮/设置已更改并在此之上启动另一个视图控制器以从音频输入中选择新设置并将其传递给setting.bundle?

There is no default mechanism for communication between Settings.bundle and your open app. Settings.bundle与打开的应用程序之间没有默认的通信机制。 The only way they can pass data between each other would be through NSUserDefaults. 他们彼此之间传递数据的唯一方法是通过NSUserDefaults。

If you were so inclined, you could store values into NSUserDefaults to indicate the last View Controller you had open, but it would have to be a manual process. 如果您愿意,可以将值存储到NSUserDefaults中,以指示您打开的最后一个View Controller,但这必须是手动过程。 Even if that were achieved, there is no place in Settings.bundle to perform logic to consume that value. 即使已实现,Settings.bundle中也没有位置执行逻辑来消耗该值。

InAppSettingsKit comes with an extension that allows you to do exactly this. InAppSettingsKit带有一个扩展,可让您精确地执行此操作。

Check the Custom ViewControllers section in the Readme. 检查自述文件中的Custom ViewControllers部分。 Of course this works only within the app, not in the settings app. 当然,这仅在应用程序中有效,而在设置应用程序中无效。 There are several option to differentiate the settings plists between Settings.app and in-App. 有几个选项可以区分Settings.app和应用程序内设置设置。 See " Custom inApp plists ". 请参阅“ 自定义inApp应用程序 ”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM