views:

31

answers:

1
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];

I have added an image to my mainview using above code, how can I remove it from view so that it will not visible in next view?

A: 

I'm not sure that I understand the reason for doing this in the first place.

But you might set a tag value for this image view and then find it by that tag:

..

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];

Not sure that all the code is correct - wrote it without XCode...

Michael Kessler