Blog Search:
Lynergy Web Application Development Blog
Monday, March 07, 2011 Blog Post
0


Posted by Matt Hudson
Categories: Technical How To

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;

// settingsViewController = [[SettingsViewController alloc] initWithTabBar];

settingsViewController = [[IASKAppSettingsViewController alloc] initWithNibName:@"IASKAppSettingsView" bundle:nil];

settingsViewController.delegate = self;

localNavigationController = [[UINavigationController alloc]

initWithRootViewController:settingsViewController];

[localControllersArray addObject:localNavigationController];

[localNavigationController release];

[settingsViewController release];

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 

 

- (void)settingsViewControllerDidEnd:(IASKAppSettingsViewController*)sender 

5.  In your SettingsViewController.m you will also need to do your imports:

#import "CustomViewCell.h"

#import "IASKSpecifier.h"

#import "IASKSettingsReader.h"

6.  In your SettingsViewController.h you will also need imports for the Delegate:


#import "IASKAppSettingsViewController.h"

 

7. I compiled and got this:


_OBJC_CLASS_$_MFMailComposeViewController


Pretty easy just make sure you include all of the Frameworks:


MessageUI Framework

UIKit Framework

CoreGraphics Framework

Foundation Framework

 

8. Add a New Settings.bundle file to your project.  There is a good article on setting up your Settings.bundle file.

 

http://www.iphonesdkarticles.com/2008/08/application-preferences.html

 

 

Happy Coding :)

Blog Post Seperator
Leave a Comment
Name:
Email Address:
(will not be published)
Comment:
 
Lynergy Web Application Development Blog
We don't just build great web sites. We build tools that make your company more efficient and we train your company to use those tools effectively.
359 E. Robinson Ave.
Springdale, Arkansas  72764
 
Toll Free: (866) 582-0358
Phone: (479) 313-6431
support@lynergy.com
Web Application Development
Training
Content Management Systems
Forms Management Software
iPhone Application Development
Mobile Web Sites
Streaming Audio
Lynergy.com Web Application Development
RealFormsArkansas.com - Realtor® Contract Management Software and Digital Signatures
Rentmind.com - Online Rent Payments for Landlords
NWAMenus.com - Northwest Arkansas Menus and Restaurant Guide