How to add a push button to an iPhone settings page?

烈酒焚心 提交于 2019-12-07 22:01:16

问题


In the Preferences app, Safari's settings page contains buttons labeled "Clear History" or "Clear Cache". The Mail App's settings page contains a big red "Delete Account" button.

Is there a way to create such a settings page with buttons for my app? I checked Apple's documentation and didn't find an element type for such buttons.


回答1:


Sadly I think you're out of luck - unless you jailbreak. To create the Settings page for your app you create a plist rather than actually coding the view itself. This brings certain restrictions such as the inability to add a button. The one core thing you can't do is to execute any code from the Settings app - all you can do is change a set of preferences.

The closest you can get is to add a switch with the label "Clear History on next starup" and check whether the user has set this whenever you start the app. Then set the settings so that the switch is set to Off.




回答2:


AppStore apps — You can't. Even if you can add a button, no code can be run, making this useless.


Jailbroken apps — Use a PreferenceBundle and create a PSButtonCell specifier. See http://www.iphonedevwiki.net/index.php?title=Preferences_specifier_plist.



来源:https://stackoverflow.com/questions/2408185/how-to-add-a-push-button-to-an-iphone-settings-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!