Basta creare un nuovo metodo init per il vostro HelpViewController e quindi chiamare il suo metodo super-init da lì ...
in HelpViewController.h
typedef enum
{
PAGE1,
PAGE2,
PAGE3
} HelpPage;
@interface HelpViewController
{
HelpPage helpPage;
// ... other ivars
}
// ... other functions and properties
- (id)initWithNibName:(NSString*)nibName bundle:(NSBundle*)nibBundle onPage:(HelpPage)page;
@end
in HelpViewController.m
- (id)initWithNibName:(NSString*)nibName bundle:(NSBundle*)nibBundle onPage:(HelpPage)page
{
self = [super initWithNibName:nibName bundle:nibBundle];
if(self == nil)
{
return nil;
}
// Initialise help page
helpPage = page;
// ... and/or do other things that depend on the value of page
return self;
}
E chiamarlo:
UIViewController *theController = [[HelpViewController alloc] initWithNibName:@"HelpView" bundle:nil onPage:PAGE1];
[self.navigationController presentModalViewController:theController animated:YES];
[theController release];
Ok, che dire dell'enum, non l'ho creato uno ancora. – Jules
typedef enum {VAL1, VAL2, VAL3} MyType; – jhabbott
Speravo che mi desse un errore in xcode se avessi cambiato initWithNibName – Jules