2014-02-17 27 views

回答

0

我使用类中的方法为这个

@interface UIView (Additions) 
- (void)removeAllSubviews 
@end 

@implementation UIView (Additions) 
- (void)removeAllSubviews 
{ 
    for (UIView *subview in self.subviews) 
     [subview removeFromSuperview]; 
} 
@end 

所以,你可以调用

[self.superview removeAllSubviews]; 

从上海华删除一切。

+0

你应该总是使用类方法的前缀 –

0
for(UIView *view in self.superview.subviews) 
{ 
    [view removeFromSuperview]; 
} 

请注意,虽然它可以删除您不知道的Apple内置程序,从而改变视图与用户交互的方式。

0

一个衬垫

[viewYouWantToRemoveFrom.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; 
相关问题