嘿伙计们,所以......让我说我有一张NSArray图片
NSMutableArray *images = [NSMutableArray new];
[images addObject:[UIImage imageNamed:@"line1.png"]];
[images addObject:[UIImage imageNamed:@"line2.png"]];
[images addObject:[UIImage imageNamed:@"line3.png"]];
[images addObject:[UIImage imageNamed:@"line4.png"]];
Run Code Online (Sandbox Code Playgroud)
现在我想使用for循环一次加载所有这些但是这里是catch ....我需要能够将图像设置为隐藏,直到用户通过交互取消隐藏.
for (UIImage *image in images) {
UIImageView *line = [[UIImageView alloc] initWithImage:image];
line.hidden = YES;
[self.view addSubview:line];
}
Run Code Online (Sandbox Code Playgroud)
但那么如何使用其他方法将隐藏的BOOL设置为NO?
作为第二个问题,如何在上面的代码中释放*行?
谢谢,达伦
一种选择是设置您的图像,如:
int nextTag = 1;
for (UIImage *image in images) {
UIImageView *line = [[UIImageView alloc] initWithImage:image];
line.hidden = YES;
line.tag = nextTag;
[self.view addSubview:line];
[line release];
nextTag++;
}
Run Code Online (Sandbox Code Playgroud)
...然后取消隐藏它们你可以做到:
UIView* imageView = [self.view viewWithTag: lineNumber];
imageView.hidden = NO;
Run Code Online (Sandbox Code Playgroud)
...假设您的用户交互处理程序能够确定用户正在与UI交互的UI中的哪一行.
| 归档时间: |
|
| 查看次数: |
12450 次 |
| 最近记录: |