Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @interface SomeViewController : UIViewController
- {
- UIImageView *imgView;
- }
- imgView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen]
- applicationFrame]];
- [imgView setImage:[UIImage imageNamed:@"someimage.png"]];
- [self addSubview:imgView];
- [imgView release];
- - (void) dealloc
- {
- [imgView release];
- [super dealloc];
- }
- @interface SomeViewController : UIViewController
- {
- UIImageView *imgView;
- }
- @property (nonatomic, retain) UIImageView *imgView;
- @synthesize imgView;
- //Create a new image view object and store it in a local variable (retain count 1)
- UIImageView *newImgView = [[UIImageView alloc] initWithFrame:self.view.bounds];
- newImgView.image = [UIImage imageNamed:@"someimage.png"];
- //Use our property to store our new image view as an instance variable,
- //if an old value of imgView exists, it will be released by generated method,
- //and our newImgView gets retained (retain count 2)
- self.imgView = newImgView;
- //Release local variable, since the new UIImageView is safely stored in the
- //imgView instance variable. (retain count 1)
- [newImgView release];
- //Add the new imgView to main view, it's retain count will be incremented,
- //and the UIImageView will remain in memory until it is released by both the
- //main view and this controller. (retain count 2)
- [self.view addSubview:self.imgView];
- - (void) dealloc
- {
- [imgView release];
- [super dealloc];
- }
- self.imgView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen]
Add Comment
Please, Sign In to add comment