Monday, August 24, 2009

Trivia for Preference Bundles.

1. How to create that red delete button?

The red delete button in VPN is in fact very easy to implement. All you need to do is add the following code:

#import <UIKit/UIPreferencesDeleteTableCell.h>
@interface PSDeleteTableCell : UIPreferencesDeleteTableCell @end
@implementation PSDeleteTableCell
-(void)setValueChangedTarget:(id)target action:(SEL)action userInfo:(NSDictionary*)info {
[self setTarget:target];
[self setAction:action];
-(UILabel*)titleTextLabel {
UILabel* res = [super titleTextLabel];
res.textColor = [UIColor whiteColor];
return res;

and then in the specifier plist, modify your button as:

{ cell = PSButtonCell;
action = nukeFromOrbit;
label = "Nuke from Orbit;
cellClass = PSDeleteTableCell;

The result is:

2. PSEditableListController

Normally list controllers inherit from the PSListController, but you can make a class inherit from PSEditableListController so that it becomes... editable! Actually, more like deletable. There will be an extra Edit/Done button on the top right hand corner, pressing it will reveal the deletion control. If you actually delete a cell, the corresponding specifier's deletionAction will be called.

3. A list of editing panes

There are several editing panes in Preferences.framework and .app. To use those panes, just use the specifier plist

{ cell = PSLinkCell;
detail = PSDetailController;
pane = PaneName;
... }

  • PSMultiValueEditingPane (Include just a PSSegmentCell, useless by itself.)

  • PSTextEditingPane (A pane containing a text field and a keyboard.)

  • RegulatoryPane (A static image showing the device is FCC approved and in other countries as well.)

  • LegalMessagePane

  • TimeZonePane (Time zone selector. The returned value doesn't contain just time zone, but also city location.)

  • RingtonePane (Note that the ringtone will be played when selected.)

No comments:

Post a Comment