假设我有3个视图控制器。我在vc0中启动vc1,然后在vc1中启动vc2。现在我希望vc2被撤掉,然后只显示vc0。这怎么可能呢?我读了一些关于代表声明的文章。但无法理解。
我有UISegmentcontrol,我在那里显示一个来自故事板的控制器,比如-vc0=[self.storyboard-instantiateViewControllerWithIdentifier=@"vc0"];并使其成为它的子视图[self.view addSubview:vc0.view];Vc0是一个tableView,它有一个要显示的详细控制器。当我点击一个单元格时,它会显示详细视图,但当详细视图被取消时,实际的segmentcontrol.view会丢失。
举个例子就太棒了。
附言:我没有使用segue作为视图控制器。相反,我使用presentModalViewController和dissetModalViewControl。
在iOS 5中,您需要执行
[self.presentingViewController.presentingViewController dismissModalViewControllerAnimated:YES]
自iOS 6起,已弃用模式视图控制器动画:。
你需要打电话给
[self.presentingViewController.presentingViewController dismissViewControllerAnimated:YES completion:^{ // Do something on completion}]
//If you want to perform something while going through views or other wise keep completion to nil as shown in below code.
或
[self.presentingViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil];
或
[self.parentViewController.parentViewController dismissModalViewControllerAnimated:YES];