Tag Archives: Storyboard

Integrating InAppSettingsKit with Storyboard, UITabBarController, and ARC

I love the concept of InAppSettingsKit.  While it’s possible to make your own settings view and hook up all your own buttons, I like the simplicity of installing a “plugin” — just copy over the files, hook it up to a view, and be done with it.

I’m using the iOS 5 SDK with a Storyboarded app, using a Tab Bar, and I was able to integrate it pretty simply after a trip to Google got me on the right track:

1) Created my Settings.bundle, including NSUserDefaultsDidChangeNotification observers as described in the Apple Settings bundle documentation.  The AppPrefs sample app helped here (specifically with the observers).

2) Copied the InAppSettingsKit directories (not the sample app) into my project.

3) Made sure I had all the necessary Apple frameworks:

  • MessageUI Framework
  • UIKit Framework
  • CoreGraphics Framework
  • Foundation Framework

MessageUI was the only one I needed to add.  Project > Targets > MyApp > Build Phases > Link Binary With Libraries and click the + icon to add any that are missing.

Before adding it, I was getting this horrible error:

missing required architecture i386 in file
Undefined symbols:
  "_OBJC_CLASS_$_MFMailComposeViewController"

The nature of the error message was completely alien to me, but — again — thank you, Internet.

4) In Storyboard editor, I added a new Navigation Controller and Table View Controller.
4a) I deleted the view controller that came along for the ride when I dragged the new navigation controller to my storyboard.
4b) I linked the navigation controller to my tab bar controller, then linked the navigation controller to the table view controller (control+click and drag).
4c) I selected the Table View in the table view controller and changed the Style of the prototype content to “Grouped”.
4d) I changed the controller class to IASKAppSettingsViewController.

Et voila, it compiled and worked. With this method I didn’t need to add any custom controllers or views; just the InAppSettingsKit files and linked a new table view to the main IASK controller.

Also worth noting: since I’m using ARC in my project, I opted for an ARC-compatible fork of InAppSettingsKit. See the ticket on Github. I used tibr’s fork.

Related:

Advertisements