PDA

View Full Version : picture hidden help




iAppleFan08
Apr 1, 2009, 12:42 AM
This is another one of my simple little problems in learning how to code in Objective-C, but this time I need to hide a picture. I have a picture that, when I press a button, I want it to hide. Then, with another button, I want the picture to come back again. Creating an IBOutlet and pointing to the picture refused to work, so I was wondering if there was any particular way I was supposed to go about this...



dejo
Apr 1, 2009, 12:55 AM
Connect the first UIButton's touchUpInside event to an IBAction that hides the image. Connect the second UIButton's event to an IBAction that shows the image. Connect the image to an IBOutlet. Code goes something like this:

- (IBAction)hideImage {
theImage.hidden = YES;
}

- (IBAction)showImage {
theImage.hidden = NO;
}

iphonedevelop18
Apr 1, 2009, 01:00 AM
the way i did it was make a clear image with no background and set the image view to it. use the code

-(IBAction)hide:(id)sender{
imageView.image = [UIImage imagenamed:@"clearimage.png"]
}


imageView is your view that you connected in IB, and make your clear image you made called clearimage.png and put it anywhere in your project. To make it come back use the same code but set the image to whatever yoour image was named.

Hope this helps!

yuanyuan
Apr 1, 2009, 01:01 AM
the way i did it was make a clear image with no background and set the image view to it. use the code

-(IBAction)hide:(id)sender{
imageView.image = [UIImage imagenamed:@"clearimage.png"]
}


imageView is your view that you connected in IB, and make your clear image you made called clearimage.png and put it anywhere in your project. To make it come back use the same code but set the image to whatever yoour image was named.

Hope this helps!I don't think there is any book for iPhone development that assumes its readers are total beginners. They assume some knowledge of Objective-C. Therefore, start with an Objective-C book and then progress to an iPhone development book.

CocoaPuffs
Apr 1, 2009, 01:11 AM
Oh, this guy is a spammer!