0
我想從UIView中刪除指標子視圖,但它刪除了它們而不僅僅是子視圖。無法從視圖中刪除子視圖?
我的看法是:
UIView * aView = [[UIView alloc] initWithFrame:CGRectMake(0.5*winSize.width-winSize.width/3, 0.85*winSize.height , winSize.width/1.5, winSize.width/8)];
aView.backgroundColor = [UIColor clearColor];
aView.tag = 31000;
UIActivityIndicatorView *av = [[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite] autorelease];
av.frame=aView.bounds;
[av setBackgroundColor:[UIColor colorWithRed:0.23 green:0.23 blue:0.23 alpha:0.85]];
av.layer.cornerRadius=4;
av.tag = 31001;
[aView addSubview:av];
[[[CCDirector sharedDirector]view]addSubview:aView];
[av startAnimating];
,我已經嘗試了許多方法去除它,我已經在這裏找到:
UIActivityIndicatorView *tmpimg = (UIActivityIndicatorView *)[[[CCDirector sharedDirector]view] viewWithTag:31001];
if(tmpimg)
[((UIView *)tmpimg) removeFromSuperview];
或
UIView *removeView;
while((removeView = [[[CCDirector sharedDirector]view] viewWithTag:31001]) != nil)
{
[removeView removeFromSuperview];
}
或
UIView * aView = [[[CCDirector sharedDirector]view] viewWithTag:31000];
if(aView)
for(UIView *subview in [aView subviews])
[subview removeFromSuperview];
,但它始終刪除他們兩個......我失去了..
你在調用之前和之後添加子視圖的日誌,並確保刪除活動指示符也會導致超級視圖被刪除? – Wain 2013-04-24 11:28:03
oops。我很愚蠢。第一個插入清晰的顏色,它仍然存在..... – Curnelious 2013-04-24 11:29:35
你有解決方案嗎? – yen 2013-04-24 11:33:57