ios开发中有时会需要对已添加过的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来区分{
[View SetHidden:YES];//隐藏此控件
[View removeFromSuperview];//删除此控件
}
}
问一个开发群的怎样删除View的子视图,被嘲讽了,这个叫苏州-追风少年的,咱自己查资料解决问题,希望能帮助到别人
网友评论