移除所有子视图
根据现在的知识,移除子视图得 循环调用 removefromsuperview 方法
比较一般的方法:
for(UIView *view in [self.view subviews])
{
[view removefromsuperview];
}
如果要移动指定的视图,可以这样:
for(UIView *mylabelview in [self.view subviews])
{
if ([mylabelview isKindOfClass:[UILabel class]]) {
[mylabelview removeFromSuperview];
}
}
或者你可以用makeObjectsPerformSelector 配合removeFromSuperview 来用,本质都是循环调用removeFromSuperview;
[view.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];