How to remove subviews from superviews and redraw on a click a button click?
float padding = 5.0;
float view_width = 95.0;
float view_height = 120.0;
int rows = 0.0f;
int columns = 0.0f;
UIView *myAddedView ;
for (int i=0; i<[product.CorrentAnswer intValue]; i++)
{
if(i%3 == 0 && i > 0)
{
columns = 0.0f;
rows += view_height;
}
myAddedView =[[[UIView alloc] initWithFrame:CGRectMake(padding+columns, rows, view_width, view_height)] autorelease];
myAddedView.backgroundColor = [UIColor clearColor];
CGRect myImageRect = CGRectMake( 40, 100.0f, 40.0f, 40.0f);
UIImageView *myImage = [[UIImageView alloc]initWithFrame:myImageRect];
NSString *imageName = [NSString stringWithFormat:@"%@",product.imagename];
[myImage setImage:[UIImage imageNamed:imageName]];
[myAddedView addSubview:myImage];
[viewarray addObject:myAddedView];
[self.view addSubview:myAddedView];
columns+= view_width;
}
i want to remove myAddedView from self.view?
hope to get answer very soon….
you can do this by assigning a tag to
myAddedView….code change :
and on the button click(when you want to remove the subview) write :
thanks