ios開發(fā)中有時會需要對已添加過的view進行刪除、隱藏等操作痢士。通常可以通過以下方法來完成
if([self.keepViewsubviews].count)
{
for(UIView*viewin[self.keepViewsubviews]) {
if(view.tag==666) {
view.hidden=YES;
}
self.keepView= (UIView*)[self.viewviewWithTag:button.tag];
UIImageView*selecetView = [[UIImageViewalloc]initWithFrame:CGRectMake(0,0,35,35)];
[selecetViewsetImage:[UIImageimageNamed:@"select"]];
selecetView.tag=666;
[self.keepViewaddSubview:selecetView];
[self.keepViewsendSubviewToBack:selecetView];
}
}
for(UIView *View in [self.View subviews])
{
if(([View isKindofClass:[UILable class]])&&(View.tag == 1))//如果有多個同類型的View可以通過tag來區(qū)分{
[View SetHidden:YES];//隱藏此控件
[View removeFromSuperview];//刪除此控件
}
}
問一個開發(fā)群的怎樣刪除View的子視圖茂装,被嘲諷了怠蹂,咱自己查資料解決問題,希望能幫助到別人