Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

iAppleFan08

macrumors newbie
Original poster
Aug 26, 2008
25
0
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

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
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:

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

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

iphonedevelop18

macrumors member
Feb 26, 2009
50
0
the way i did it was make a clear image with no background and set the image view to it. use the code
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

macrumors newbie
Mar 31, 2009
2
0
the way i did it was make a clear image with no background and set the image view to it. use the code
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.