UIImage *image = [UIImage imageNamed:@"logo_header.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.frame = CGRectMake(0, 10, 320, 28);
[self.navigationController.view addSubview:imageView];
我使用上面的代码在主视图中添加了一个图片,如何将其从视图中删除,以便在下一个视图中无法显示?
答案 0 :(得分:2)
我不确定我是否理解这样做的原因。
但您可以为此图片视图设置标记值,然后通过该标记找到它:
..
UIImage *image = [UIImage imageNamed:@"logo_header.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.frame = CGRectMake(0, 10, 320, 28);
imageView.tag = 100001;
[self.navigationController.view addSubview:imageView];
// Why don't you release the image view?
[imageView release];
..
UIView *imageView = [self.navigationController.view viewWithTag:100001];
[imageView removeFromSuperView];
不确定所有代码是否正确 - 在没有XCode的情况下编写代码......