In building a new iPhone application, we decided to add In-App Settings. Apparently there is a lot of "hub-ub" about this, because some people believe you should use the settings system that iOS provides. Personally, I don't get caught up in all the rhetoric back and forth. I like the settings being in the application, because I don't think that most people understand the Settings pane and how it works. The settings page also gets very long, and I prefer to use it to hide special settings rather than for all common settings.
That being said, I decided to add my common settings to my application. I was surprised to discover that there is no extended UITableView that can be used like a Settings pane. So I came across a StackOverflow post about InAppSettingsKit. There is also another Framework called InAppSettings, if you decide you would like an alternative.
This post will cover InAppSettingsKit by FutureTap. I have to say that it seems like a very good project, but I was not able to find any documentation. They provided a GitHub link to an example app, but I thought there would at least be preliminary documentation of how to set it up. Needless to say that's why I'm writing this post. :)
1. To start, download the InAppSettingsKit from GitHub. Unzip it, and copy the InAppSettingsKit directory from the sample project to your project.
The sample application loads the settings three ways: a modal popup, a tab bar item, and a navigation panel. The tab bar item is the one I was looking for, but there project was configured a little differently than mine. I init my tab bar controller UIViewControllers in my main app delegate. I also had my own init function, so I would have to work around that.
2. Create a UIViewController for your settings pane. In your .h interface:
@interface SettingsViewController : IASKAppSettingsViewController <IASKSettingsDelegate,UITextViewDelegate>
3. Init your SettingsViewController somewhere (I used the App Delegate).
// settingsViewController = [[SettingsViewController alloc] initWithTabBar];
settingsViewController = [[IASKAppSettingsViewController alloc] initWithNibName:@"IASKAppSettingsView" bundle:nil];
settingsViewController.delegate = self;
localNavigationController = [[UINavigationController alloc]
tabBarController.viewControllers = localControllersArray;
4. Copy the delegate functions into your SettingsViewController.m file. Here are the functions you will need to copy out of the Sample App provided by InAppSettingsKit.
- (CGFloat)tableView:(UITableView *)tableView
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderForKey:(NSString*)key
- (UIView *)tableView:(UITableView *)tableView viewForHeaderForKey:(NSString*)key
- (CGFloat)tableView:(UITableView*)tableView heightForSpecifier:(IASKSpecifier*)specifier
- (UITableViewCell*)tableView:(UITableView*)tableView cellForSpecifier:(IASKSpecifier*)specifier
- (void)textViewDidChange:(UITextView *)textView
5. In your SettingsViewController.m you will also need to do your imports:
6. In your SettingsViewController.h you will also need imports for the Delegate:
7. I compiled and got this:
Pretty easy just make sure you include all of the Frameworks:
8. Add a New Settings.bundle file to your project. There is a good article on setting up your Settings.bundle file.
Happy Coding :)