What I want to realize is:
When I touch a button, the image display on the view for 1 sec, then the image disappear.
I know that a NSTimer will help, but i dont know how to write the right code…need your help, thanks.
- (IBAction)bodytouched:(id)sender {
bodytouchedimage.hidden = NO;
bodytouchedimage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"beated.jpg"]];
bodytouchedimage.userInteractionEnabled = YES;
timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(showPictures:) userInfo:nil repeats:NO];
}
- (void)showPictures:(NSTimer *)timer {
bodytouchedimage.hidden = YES;
}
What you should to is call the
showPicturesfunction when you touch the button and then within theshowPicturesmethod you add aNSTimerthat will call a hidePictures method 1 second later