Can you put a button in the Preferences for your iPhone app? - iphone

I'm building an iphone app, and I wanna use the iPhone's built in Preferences stuff. It looks like I put options in there, but I'm interested in putting a Reset button in the Prefs. I see that Apple's built-in apps like Safari have buttons in their prefs (Clear History, Clear Cookies, etc). I don't see a way to do this for SDK apps. Help!

Your Settings bundle cannot contain any runnable code, so it's not possible to have buttons like safari (Clear History, Clear Cookies, etc).
Safari is a builtin application provided by Apple, therefore it has access to apis/privileges that normal AppStore applications don't.
You can see the list of possible elements here.

One thing you can do, since you can set your own app's preferences during runtime, is create a "Reset preferences on next run" toggle.
When your app starts up, check for this setting and act accordingly if it is set to "On". Don't forget to reset the toggle as well. ;-)
Here's a Q&A that explains how to do this: How to change the app preference settings through code?

Related

iPhone - Change icon of the app programmatically at runtime

I can read that changing the app icon programmatically at runtime is not possible, at least since iOS 3.0.
But... I regulary can see on "App" websites apps that can put icons on the springboard. The first I remember is that kind of app that you give a friend's picture from your album, and it creates an icon so you can call him just clicking on that icon:
http://itunes.apple.com/fr/app/speedtouch-the-best-home-screen/id378360978?mt=8
http://itunes.apple.com/fr/app/desktop-shortcut/id421701004?mt=8
http://itunes.apple.com/fr/app/appbutler-app-organizer/id327391626?mt=8
http://itunes.apple.com/fr/app/tap4music/id365578914?mt=8
So I guess, is it still impossible to change the app icon programmatically at runtime?
Update
Apple have changed this, you can do this now: https://developer.apple.com/documentation/uikit/uiapplication/2806818-setalternateiconname
Original Answer
What you're thinking of here are WebClips, which are basically shortcuts to websites on the home screen. An actual application cannot change it's icon at runtime, as it's defined in the static Info.plist file.
The only exception to this rule is Newsstand applications.
This is now possible in iOS 10.3 using the UIApplication.setAlternateIconName(_:completionHandler:) API.
See my answer to this question: https://stackoverflow.com/a/44966454/233602
Changing your actual icon (other than, e.g, badging) would require changing the app bundle. I'm pretty sure that you don't have write access to the bundle, and in any event this should change the code signature, causing the OS to prevent launching.
So, no. Apps can put links to web sites, but not change their own app.

Adding a button to an iPhone prefs / settings bundle?

Just wondering if it's possible to add a button like the "Clear History", "Clear Cookies" etc buttons in the Safari preferences to your own app's settings bundle? Been digging through the dev docs and can't find any plist specifier for a button, so I'm wondering if this is an internal API for the Apple guys?
After you hit the button, you get an action sheet asking you whether you really want to do it, and then presumably there is some callback based on the user's input.
Also noticed that the Nike + iPod settings have a clear button in them, but again, that app might have access to internal APIs that we don't.
No, this is not possible. The system only supports interacting with the values from within your app. You can't run code from the settings app so a button would be useless.
Nike+iPod is a root application. Anything running under root can run code from basically anywhere (with restrictions, Sandbox is a b**ch) If you're interested you can make a jailbreak preferencebundle with Theos or iOSOpenDev! Which allows you to make a root bundle that can run button action code.
iOSOpenDev, which extends Xcode for iOS jailbreak-style project development, provides project templates that have a check boxes to include either a simple PreferenceLoader (plist-based) or a full PreferenceLoader bundle.

iPhone Settings.bundle - how to disable/enable a setting based on other settings?

Hard to explain, but luckily there's an example. On an iPhone, when you go to Settings > Nike + iPod, in the app's settings, when you set Nike+iPod to off, it disables the rest of the settings. How do I do that? Use one setting to disable or toggle off another setting?
For AppStore apps, no you can't do that, period.
Detail: Nike+iPod is using a different mechanism known as "Preferences Bundle", which allows more kinds of specifiers (e.g. buttons) and running code. To disable settings live, one need codes. "Settings Bundle" which AppStore allows cannot run code. So that cannot be done.

How do you send a user to your app's settings from iPhone/iPad?

Is there a way to launch the iPhone/iPad's settings from within your app?
Check this out: It is a framework to display the apps's settings in both places, or just just on the app using the same type of display as the settings pane.
There is no way to do this. What apps usually do is recreate the same view the user would see if they opened the settings and then display that in-app.

Display iphone application settings within your application

The iphone supports a means of defining your application's settings such that it will automatically create a UI in the Settings app. I want to also allow the user to edit the application settings within the application but it'd be nice to reuse the same UI that is automatically created.
See: Application Settings
Is there a way to have your application display the settings using the same UI that the Settings application does?
No there is not a way to reuse the UI.
There is, however, a way to reuse the data. Settings.app will put the settings in NSUserDefaults under the keys specified in your Settings.bundle plist file. You can alter those values in your app, then switch to Settings.app and see that it will have changed to reflect your new values. This is really nice if you want to allow the user to edit settings in the app (if that's what they're used to) or in Settings.app (if that's what they're used to).
EDIT #1
You may want to look at this thread. There is a library called mySettings that would make building this easier.
EDIT #2
There are a couple libraries available now that do this:
InAppSettings
InAppSettingsKit