0

我有两个视图控制器,称它们为“ViewControllerA”和“ViewControllerB”。当应用程序加载时,会显示 ViewControllerA。在 ViewControllerA 中touchesEnded:withEvent:,它调用presentViewController:ViewControllerB。ViewControllerB 的加载工作正常;唯一的问题是当它们转换时, ViewControllerA 变黑。即使在转换到 ViewControllerB 时,如何让 ViewControllerA 继续查看其内容?如果它是相关的,我使用自定义转换,这里演示:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.7f];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationRepeatCount:1.0f];
[UIView setAnimationRepeatAutoreverses:NO];
[UIView setAnimationDelegate:self];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

toViewController.view.frame = self.view.bounds;
[self presentViewController:toViewController animated:NO completion:nil];

[UIView commitAnimations];
4

1 回答 1

1

首先,您应该使用自 iOS 4 以来推荐的较新的基于块的方法。如果您使用具有完成块的方法,您可以在那里执行 presentViewController:animated (当您呈现带有动画 NO 的视图控制器时,它将立即删除旧控制器的视图,这就是你的问题)。这是一个将视图从小尺寸扩展到全尺寸的示例:

-(IBAction)doStuff:(id)sender {
    self.toViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"ToVC"];
    self.toViewController.view.transform = CGAffineTransformMakeScale(.01, .01);
    [self.view.window addSubview:self.toViewController.view];
    [UIView animateWithDuration:2.0 animations:^{
        self.toViewController.view.transform = CGAffineTransformIdentity;
    } completion:^(BOOL finished) {
        [self presentViewController:self.toViewController animated:NO completion:nil];
    }];
}
于 2013-09-18T01:24:23.737 回答