在 while 循环中隐藏/显示 UI 元素
这可能很简单,但我想在循环中隐藏不同命名的 UI 元素:
int i = intFigures + 1;
while (i <= 16) {
imagei.hidden = TRUE;
i++
}
本质上,我需要根据记录显示 1 到 16 之间的多个图像。如果该特定记录只有 12 个图像,我想隐藏 UIImage
13 到 16。如何根据增量设置我试图隐藏的 UIImage
环形?
This is probably an easy one but I want to hide variably named UI elements in a loop:
int i = intFigures + 1;
while (i <= 16) {
imagei.hidden = TRUE;
i++
}
Essentially I need to display a number of images between 1 and 16 depending on the record. If that particular record only has 12 images, I want to hide UIImage
13 through 16. How do I set the UIImage
that I am trying to hide based on the increment of the loop?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能仅将变量 i 附加到图像变量的名称中。您可能已经在数组中拥有了 ImageView,为什么不直接迭代它呢。
或者,如果您的 imageView 直接添加到当前视图,您可以只迭代其子视图。添加图像时,您可以为某些 imageView 指定特定标签,以便稍后识别它们。例如:
You cannot just append the variable i to the name of the image variable. You probably already have your ImageViews in an array, why not just iterate over that.
Alternatively, if your imageViews are added directly to your current view, you could just iterate over its subviews. When you add the images, you could give certain imageViews a specific tag so that you can later identify them. Such as: