presentViewController会自动销毁以前的视图吗?

时间:2012-09-27 05:08:33

标签: objective-c xcode segue

我使用一堆自定义segue从一个视图控制器视图切换到另一个视图控制器视图:

[self performSegueWithIdentifier:@"createTeamAccountSegue" sender:self];

我的问题是,以前的视图是否会在iOS5和6中自动销毁?

我不得不创建自定义segues以转到下一个视图,然后反向创建另一个新的segue动画以返回到最后一个视图。只要他们不继续堆放,那么这应该没问题呢?

编辑:我应该向您展示我的自定义UIStoryboardSegue类的总体布局:

- (void) perform {

UIViewController *sourceViewController = (UIViewController *) self.sourceViewController;
UIViewController *destinationViewController = (UIViewController *) self.destinationViewController;

UIView *parent = sourceViewController.view.superview;

[parent addSubview:destinationViewController.view];
[parent sendSubviewToBack:destinationViewController.view];

sourceViewController.view.layer.masksToBounds = NO;
sourceViewController.view.layer.cornerRadius = 8; // if you like rounded corners
sourceViewController.view.layer.shadowOffset = CGSizeMake(0,0);
sourceViewController.view.layer.shadowRadius = 10;
sourceViewController.view.layer.shadowOpacity = 1;

destinationViewController.view.frame = CGRectMake(0, 20, destinationViewController.view.frame.size.width, destinationViewController.view.frame.size.height);
sourceViewController.view.frame = CGRectMake(0, 20, sourceViewController.view.frame.size.width, sourceViewController.view.frame.size.height);

[UIView animateWithDuration:.3 delay:0.0 options:UIViewAnimationCurveEaseInOut animations:^
 {
     sourceViewController.view.frame = CGRectMake(0, parent.frame.size.height, sourceViewController.view.frame.size.width, sourceViewController.view.frame.size.height);

 } completion:^(BOOL finished)
 {
     [sourceViewController presentViewController:destinationViewController animated:NO completion:NULL];
 }];

}

1 个答案:

答案 0 :(得分:3)

如果您正在UINavigationController中进行segues,那么不会,它们不会被销毁。要回到一个你应该使用[self.navigationController popViewControllerAnimated:YES];