Alternatively, this can be done with tags Set up the imageView in viewDidLoad or similar UIImageView * imageView = UIImageView alloc initWithFrame:CGRectMake(0, 0, 175, 175); imageView setTag:123; self. View addSubview:imageView; imageView release Then any time you want to change the image, you just have to use: (UIImageView*)self. View viewWithTag:123 setImage:UIImage imageWithCGImage:imageRef Just another option, the other answers will work just as well.
Alternatively, this can be done with tags. //Set up the imageView in viewDidLoad or similar UIImageView * imageView = UIImageView alloc initWithFrame:CGRectMake(0, 0, 175, 175); imageView setTag:123; self. View addSubview:imageView; imageView release; Then any time you want to change the image, you just have to use: (UIImageView*)self.
View viewWithTag:123 setImage:UIImage imageWithCGImage:imageRef; Just another option, the other answers will work just as well.
At the moment, you're creating a new UIImageView and adding it to the list of sub views. As you're seeing, you then end up with two image views. What you want is to just change the image displayed by the first view.
Retain a handle to the UIImageView you create (probably as a member field), and when you want to change the image, just write UIImage *img = UIImage imageWithContentsOfFile: NSBundle mainBundle pathForResource:@"myImage2" ofType:@"png"; imageView. Image = UIImage imageWithCGImage:imageRef.
I just spent a day looking at this tricky issue, so I thought I would share how to change images on a UIImageView. Too many posts regarding this were not able to show a simple way of doing this so here goes... If you want to change an image displayed on an imageView In your . H IBOutlet UIImageView *imageView; @property (nonatomic, retain, readwrite) IBOutlet UIImageView *imgView; and in your .
M -(void)viewDidLoad { super viewDidLoad; self. ImageView = UIImageView alloc initWithFrame:CGRectMake(133, 230, 60, 60); self.imageView. Image = UIImage imageNamed:@"firstPicure.
Png"; self. View addSubview:self. ImgView; } Now change your image displayed in your imageView.
One nice thing about this method is that imageNamed will return an autorelease instance of an image so you can avoid memory leaks and for simplicity sake you use performSelectorOnMainThread to handle the change -(void)changeImage { self. ImageView performSelectorOnMainThread:@selector(setImage:) withObject: UIImage imageNamed:@"secondPicture. Png" waitUntilDone:YES; }.
I am not sure why you are bothering to crop the image; just set the contentMode property appropriately. Alternative approach: UIImage *image = UIImage imageNamed:@"myImage. Png"; UIImage *image2 = UIImage imageNamed:@"myImage2.
Png"; UIImageView *imageView = UIImageView alloc initWithFrame:...; imageView. ContentMode = UIViewContentModeTopLeft; imageView. Image = image; self.
View addSubView:imageView; ... imageView. Image = image2.
Can I get back the imageView from self. View? – Tattat May 3 '10 at 13:17 You can always use a tag and ask self.
View for viewWithTag: – Paul Lynch May 3 '10 at 13:24.
I just spent a day looking at this tricky issue, so I thought I would share how to change images on a UIImageView. And in your . Now change your image displayed in your imageView.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.