0
如何從超級視圖中刪除子視圖並點擊按鈕點擊重繪?如何從超級視圖中刪除子視圖並單擊按鈕單擊重新繪製?
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;
}
我想從self.view中刪除myAddedView?
希望能得到很快回答....
以及感謝這樣一個快速回復隊友,但我只是用下面的代碼的幫助,這樣做,如果(viewarray.count> 0){ \t \t \t爲(UIView的*在viewarray視圖) \t \t \t { \t \t \t \t [view removeFromSuperview]; \t \t \t} \t \t \t \t \t} – 2011-04-10 15:06:35
我不知道爲什麼你使用這個viewarray因爲系統本身具有規定上添加了所有的意見.....所以你只需要來標記不同的看法值........這將幫助您節省內存。謝謝 – Ravin 2011-04-10 15:13:35