这些常用的代码老是记不住,想想还是好记性不如烂笔头就给记下了。
//获取页面上所有控件(因为所有控件均是View的子类,所以获取View即可)
NSArray *arr_view = self.view.subviews;
for (UIView *v in arr_view) {
[v removeFromSuperview];//从SuperView上移除
}
//移除页面上所有相应控件(此处以Button为例)
NSArray *arr_view = self.view.subviews;
for (UIView *v in arr_view) {
if ([v isKindOfClass:[UIButtonclass]]) {
[v removeFromSuperview];
}
}
//移除Tag为10 的控件
NSArray *arr_view = self.view.subviews;
for (UIView *v in arr_view) {
if ([v.tag == 10]) {
[v removeFromSuperview];
}
}