Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How to write a custom initializer that prevents viewDidLoad being called?
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if ( self ) {
- }
- return self;
- }
- - (id) initWithFilename:(NSString *)aFilename {
- self = [self initWithNibName:@"WallpaperDetailsViewController" bundle:nil];
- if ( self ) {
- self.filename = aFilename;
- }
- return self;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Create a UIImageView to display the wallpaper
- self.wallpaper = [[UIImageView alloc] initWithImage:[UIImage imageNamed:self.filename]];
- // ...
- }
- WallpaperDetailsViewController *detailsViewController = [[WallpaperDetailsViewController alloc] initWithFilename:@"foobar.png"];
- [[self navigationController] pushViewController:detailsViewController animated:YES];
- - (id) initWithFilename:(NSString *)aFilename {
- // Call super's designated initializer
- self = [super initWithNibName:@"WallpaperDetailsViewController"
- bundle:nil];
- if ( self ) {
- self.filename = aFilename;
- }
- return self;
- }
- - (id) initWithFilename:(NSString *)aFilename {
- self = [self initWithNibName:@"WallpaperDetailsViewController" bundle:nil];
- if ( self ) {
- filename = [aFilename retain];
- wallpaper = [[UIImageView alloc] initWithImage:[UIImage imageNamed:aFileName]];
- }
- return self;
- }
Add Comment
Please, Sign In to add comment