【发布时间】:2011-04-13 13:00:12
【问题描述】:
我在滚动视图和普通视图中有几张图片。我想通过“if 语句”检查此图像是否在我的滚动视图中。
我把我的图片放在滚动条中:
[scroller insertSubview:image belowSubview:self.view];
提前致谢!
【问题讨论】:
标签: iphone cocoa-touch image uiscrollview
我在滚动视图和普通视图中有几张图片。我想通过“if 语句”检查此图像是否在我的滚动视图中。
我把我的图片放在滚动条中:
[scroller insertSubview:image belowSubview:self.view];
提前致谢!
【问题讨论】:
标签: iphone cocoa-touch image uiscrollview
你试过了吗:
[scroller.subviews containsObject:image];
?
【讨论】:
如果您只想添加尚未添加的图像,则可以使用标签。每个UIImageView 都应该有一个唯一的标签。
const int uniqueImageTag = 10001;
image.tag = uniqueImageTag;
if ([scroller viewWithTag:imageTag] == nil) {
[scroller insertSubview:image belowSubview:self.view];
}
【讨论】:
类似:
UIView *parent = [self.imageView superview];
if (parent == scroller) {
//yep
}
【讨论】: