ios - 在呈现另一个 View Controller 时,如何阻止 "from" View 变黑?

标签 ios objective-c uiviewcontroller transition ios7

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

[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];

最佳答案

首先,您应该使用自 iOS 4 以来推荐的基于 block 的较新方法。如果您使用具有完成 block 的方法,则可以在那里执行presentViewController:animated(当您呈现带有动画的 View Controller 时) ,它会立即删除旧 Controller 的 View ,所以这是你的问题)。下面是一个将 View 从小尺寸扩展到完整尺寸的示例:

-(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];
    }];
}

关于ios - 在呈现另一个 View Controller 时,如何阻止 "from" View 变黑?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18862141/

相关文章:

ios - 在多个收藏 View 中显示电影列表的详细 View

ios - 如何更改 BarButtonItem 的水平位置

ios - Restkit - 预期对象映射错误

objective-c - 从详细 View 返回后, TableView 不再是 searchResultsTableView

ios - 确定是否因为子模态外观而调用 viewWillDisappear

ios - 如何从 SKScene 到 UIViewController?

ios - UITableView 部分边框

javascript - 使用 Objective-C 解析包含未被 ""包围的键的 JSON

iphone - iAd 不显示横幅广告

ios - 是否每个具有 'Edit' 或 'Done' 按钮的 View 都​​需要位于 UINavigationController 内?