PSRootController

From iPhone Development Wiki
Revision as of 02:59, 11 April 2016 by Uroboro (talk | contribs) (Unnecessary change inconsistent with standard)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

PSRootController is an abstract class that represents the root controller in a Preferences-like application.

Subclassing

A subclass of PSRootController should override -setupRootListForSize:. According to how Preferences.app is implemented, the method should look like this:

@interface MyRootController : PSRootController
@end
@implementation MyRootController
-(void)setupRootListForSize:(CGSize)size {
	PSSpecifier* spec = [[PSSpecifier alloc] init];
		
	PSListController* root = [[myFirstListController alloc] initForContentSize:size];
	[spec setTarget:root];
	root.rootController = self;
	[root viewWillBecomeVisible:spec];
	[spec release];
	root.parentController = self;
	
	[self pushController:root];
	[root release];
}
@end

Using

To add the root controller view to your app, use this code:

-(void)applicationDidFinishLaunching:(UIApplication *)application {
...
	window.frame = [UIScreen mainScreen].applicationFrame;
...
	MyRootController* rootCtrler = [[MyRootController alloc] initWithTitle:@"Some Title" identifier:@"com.yourcompany.appName"];
	[window addSubview:[rootCtrler contentView]];
...
}

External links