Sunday 3 March 2013

In-App Settings with InAppSettingsKit


According to Apple’s “iOS Human Interface Guidelines” section “De-emphasize Settings”, the preferred way to provide settings for your app is through the Settings.app. If your app contains frequently accessed preferences, however, presenting them directly inside the application may be a better option. Personally, I feel that a hybrid solution, providing access to the settings page in both places, is ideal.
In this iDevBlogADay post, I want to discuss an easy way to add in-app application preference, using the iOS Settings Bundle and InAppSettingsKit. InAppSettingsKit is an open source framework authored by Luc Vandal and Ortwin Gentz. It allows developers to add in-app settings to their iPhone apps by mimicking Settings.app’s behavior.
I’m currently on vacation, so apologies for the shortness of this post. Leave a comment if you need me to discuss anything in detail. Let’s begin…

Creating and Modifying the Settings Bundle

First you must create a settings page in Settings.app. This step is very straight forward. The instructions are outlined in Apple’s “iOS Application Programming Guide” section “Implementing Application Preferences”.
Your app will need to reconfigure itself during startup as well as during runtime. It’s recommended that you do all reconfiguration inside a -reconfigure method, so there won’t be any code duplication.

Creating In-App Settings

Add InAppSettingsKit’s source files to your Xcode project:
  1. Clone the InAppSettingsKit GitHub respository.
  2. In Xcode’s Navigator, right click on your project, choose Add File to “YourProjectName.”
  3. Inside the InAppSettingsKit project, you will see two directories: InAppSettingsKit and InAppSettingsKitSampleApp; select the former, click on the checkbox for Copy items into destination group’s folder (if needed), and then click Add.
Create a delegate that conforms to the IASKSettingsDelegate protocol. In the current version, -settingsViewControllerDidEnd: is the only required method. Within this method is where the app should reconfigure itself for changed settings. Fortunately, we had conveniently created a method for reconfiguring the app, so we’ll just call it.
- (void)settingsViewControllerDidEnd:(IASKAppSettingsViewController*)sender {
 [self dismissModalViewControllerAnimated:YES];
 [self reconfigure];
}
Finally, allocate an instance of IASKAppSettingsViewController, initialize it with your delegate and push it onto the stack.
You should now have a settings page in Settings.app as well as in your app. I hope you found this post useful.

2 comments:

  1. Hi, I am new to iOS and wanted to integrate the inAppSettingsKit for my app. I have downloaded the InAppSettingsKitCode and added in my project. Created a settings view controller. But I am stuck as to how to go from here. Can you please share your reconfigure method?

    ReplyDelete
  2. I simply observed this weblog and feature excessive hopes for it to continue. hold taking region the precise con, its hard to discover great ones. i've appendage to my favorites. thank you. App Cloner

    ReplyDelete