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)];
试试这个