Sunday, September 7, 2014

How to add a child pane (page) in iOS setting app

The following steps can be used to to add a child pane (page) in iOS settings app for your application:
1. open settings.bundle, select the item after which you want to add the new item to open the child pane.
2. select "Editor->Add Item" menu to add a new dictionary item
3. expand the new dictionary item, change the type item to "child pane"
4. change the title item to the text you want to display
5. add a new filename item, set it to the plist file name, for example "mychildsettings"
6. open the folder of settings.bundle in Finder, then show the content of the settings bundle
7. copy setting.plist and renamed the copied file to mychildsettings.plist
8. open mychildsettings.plist in xcode and update its content to the settings you want to show in the child pane

When using NSUserDefault interface to get and set the item value defined in child pane page, there is no difference as the item defined in main settings plist file. Just need to specify the key to get and set the item value. Similarly, using registerDefault method also has no difference on the items.

The only small difference is if you need to read the default value defined in the child plist file for a item, you will need to specify the plist file name as below

NSDictionary *settingsInfo = [NSDictionary dictionaryWithContentsOfFile:[
                                                                             [[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"bundle"] stringByAppendingPathComponent:@"mychildsettings.plist"]];

NSLog(@"%@", settingsInfo);

Note the key in NSUserDefault is case sensitive.

No comments:

Post a Comment