I have looked on here and found a few examples but nothing works so here goes…
I have a subview which is started and works fine, the camera takes a pic and then a thumbnail appears at the bottom right, when clicked I want the subview released but no matter how I try I can’t get rid of the subview!
Code:
-(void)onSingleTap:(UITouch*)touch {
NSLog(@"onSingleTap");
UIImageView *eyes = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"binocs.png"]] autorelease];
eyes.tag = EYES_TAG;
[self.overlayView addSubview:eyes];
[camera takePicture];
}
Then the thumbnail action:
- (void)thumbnailTapped:(id)sender {
self.view.alpha = 99.0f;
UIButton *binocsButton = (UIButton*)[self.view viewWithTag:BINOCS_BUTTON_TAG];
binocsButton.hidden = YES;
}
So my subView is called eyes and I just need to clear that view under the thumbnail tapped action. Any ideas would be fantastic!
I’m not sure I follow entirely, but don’t you just want to add this to the bottom of
thumbnailTapped::By the way, rather than using tags it’s probably better to store a reference to the views that you want to access as an ivar of your view controller class. I would add this to your property definitions:
Then synthesise them and when you create those objects, assign to the properties and then you can access them easier later. Using tags I found in the past gets quite annoying as if the view is at the bottom of a complex view hierarchy you can’t access it easily. If you do do this, remember to also release them in your
dealloc(unless you’re using ARC).