Reputation: 1806
I've got several images inside a scrollview and within my normal view. I'd like to check by means of an "if statement" if this image is inside my scrollview or not.
i put my images inside the scroller with:
[scroller insertSubview:image belowSubview:self.view];
thanks in advance!
Upvotes: 0
Views: 162
Reputation: 578
something like:
UIView *parent = [self.imageView superview];
if (parent == scroller) {
//yep
}
Upvotes: 0
Reputation: 6102
If you want to add an image only if it is not added yet you can use tags. Each UIImageView
should have a unique tag.
const int uniqueImageTag = 10001;
image.tag = uniqueImageTag;
if ([scroller viewWithTag:imageTag] == nil) {
[scroller insertSubview:image belowSubview:self.view];
}
Upvotes: 0