Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/114.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 从Objective中的UIView中删除图形矩形_Ios_Objective C_Uiview - Fatal编程技术网

Ios 从Objective中的UIView中删除图形矩形

Ios 从Objective中的UIView中删除图形矩形,ios,objective-c,uiview,Ios,Objective C,Uiview,我曾经使用以下代码在UIView内部创建矩形(例如:“candleContainer”): UIView *myBox = [[UIView alloc] initWithFrame:CGRectMake(marginX, marginY, rectWidth, rectHeight)]; [self.candleContainer addSubview:myBox]; 但是如何删除所有或每个已经绘制的矩形呢。我是通过从超级视图中删除'candleContainer'ui视图来实现的。但这不

我曾经使用以下代码在UIView内部创建矩形(例如:“candleContainer”):

UIView *myBox  = [[UIView alloc] initWithFrame:CGRectMake(marginX, marginY, rectWidth, rectHeight)];
[self.candleContainer addSubview:myBox];

但是如何删除所有或每个已经绘制的矩形呢。我是通过从超级视图中删除'candleContainer'ui视图来实现的。但这不是真正的解决办法,对吗?。我只想删除那些矩形。我该怎么做呢?

首先,您必须从self.candleContainer获取所有UIView对象!然后将其从self.candleContainer中删除

 NSArray *viewsToRemove = [self.view subviews];

    for (UIView *view in viewsToRemove) {

        [view removeFromSuperview];
    }
for (UIView *view in self.candleContainer) 
{
    [view removeFromSuperview];
}

或者您可以向UIView对象添加标记!然后您可以通过viewWithTag:method获取它,然后将其从self.candleContainer中删除

首先,您必须从self.candleContainer获取所有UIView对象!然后将其从self.candleContainer中删除

for (UIView *view in self.candleContainer) 
{
    [view removeFromSuperview];
}

或者您可以向UIView对象添加标记!然后您可以通过viewWithTag:method获取它,然后将其从self.candleContainer中删除

首先,您必须从self.candleContainer获取所有UIView对象!然后将其从self.candleContainer中删除

for (UIView *view in self.candleContainer) 
{
    [view removeFromSuperview];
}

或者您可以向UIView对象添加标记!然后您可以通过viewWithTag:method获取它,然后将其从self.candleContainer中删除

首先,您必须从self.candleContainer获取所有UIView对象!然后将其从self.candleContainer中删除

for (UIView *view in self.candleContainer) 
{
    [view removeFromSuperview];
}
或者您可以向UIView对象添加标记!然后您可以通过viewWithTag:method获取它,然后将其从self.candleContainer中删除