Ios7 使用removeFromSuperview一次性删除添加的视图控制器视图

Ios7 使用removeFromSuperview一次性删除添加的视图控制器视图,ios7,uiview,xcode5,Ios7,Uiview,Xcode5,我以以下方式添加了viewcontrollers: 在第一个视图控制器中: [self.view addsubview:secondViewcontroller.view]; [self.view addsubview:thirdViewcontroller.view]; [self.view addsubview:fourthViewcontroller.view]; 然后在第二个视图控制器中: [self.view addsubview:secondViewcontroller.vie

我以以下方式添加了
viewcontrollers

在第一个
视图控制器中

[self.view addsubview:secondViewcontroller.view];
[self.view addsubview:thirdViewcontroller.view];
[self.view addsubview:fourthViewcontroller.view];
然后在第二个
视图控制器中:

[self.view addsubview:secondViewcontroller.view];
[self.view addsubview:thirdViewcontroller.view];
[self.view addsubview:fourthViewcontroller.view];
然后在第三个
视图控制器中:

[self.view addsubview:secondViewcontroller.view];
[self.view addsubview:thirdViewcontroller.view];
[self.view addsubview:fourthViewcontroller.view];
现在我在
fouthViewcontroller
中,想使用
removeFromSuperview
方法返回到
firsiViewController


我们如何才能做到这一点?有没有其他方法可以做到这一点。我不想使用
UINavigationController

尝试下面的代码,它可能会工作

NSArray * subviews = [self.view subviews];
    int cnt = [subviews count];
    for(int j=cnt-1; j >=0 ; --j )
    {
        UIView * sview = [subviews objectAtIndex:j];
        [sview removeFromSuperview];
    }
一排

[self.view.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
试试这个