切换设置捆绑开关时显示警报
我想在切换 iPhone 应用程序设置包的开关时显示警报。谁能帮我看看该怎么做。
I want to show an alert when i toggle the switch of the iPhone application settings bundle. Can anyone please help me out how to do it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当 Settings.app 中的开关切换时,您的应用程序将处于后台。但是,如果您会阅读开发者文档,您会看到有一个可供您订阅的
NSUserDefaultsDidChangeNotification
,并且当应用程序返回前台时显示警报。阅读文档并展示更多的研究成果确实有帮助,这是开发人员每天所做的事情。
When a switch in Settings.app is toggled, your app is in the background. However, if you would have read the Developer documentation you would have seen that there is a
NSUserDefaultsDidChangeNotification
available that you can subscribe to and show your alert when the app is back in the foreground.Reading the documentation and showing a little more research effort really helps, it's what developers do every day.