我的应用程序有一个分离的主从界面:当用户点击屏幕细节侧的特定按钮时,我使用 UIModalTransitionStyleFlipHorizontal
modalTransitionStyle
这样我可以仅以模态方式呈现一个新 Controller ,并让它看起来好像详细信息面板已“翻转”到新界面。
虽然这在 iPhone 上运行良好,但当我在 iPad 上尝试时,新的模态 Controller 从屏幕的细节一侧翻转,但在动画结束时,它覆盖了整个屏幕。
如何使 Controller 仅在屏幕的详细信息一侧翻转?
最佳答案
如果您还没有弄清楚这一点,那么您已经完成了大部分工作。您需要为“当前上下文”定义模态视图的表示上下文,以便它仅在详细 View 中运行,而不是在整个父 View 中运行。
执行此操作的最简单方法是使用 segue 在 Storyboard中设置 View 。在 IB 中,创建新的 View Controller ,添加一个 segue 并通过给它命名为“flipper”来编辑 segue 行,将其设置为模态,将其设置为翻转并将其呈现设置为“当前上下文”。
一旦设置了这些属性,您就可以继续到 View Controller - 但是从详细 View Controller 启动它,如下所示:
[self performSegueWithIdentifier:@"flipper" sender:self];
如果您需要在代码中进行转换,它看起来像这样:
UIViewController *abc = [self.storyboard instantiateViewControllerWithIdentifier:@"flipper"];
[abc setModalPresentationStyle:UIModalPresentationCurrentContext];
[abc setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentViewController:abc animated:YES completion:nil];
祝你好运。
关于objective-c - 具有主从 Controller 的模态视图 Controller 大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12591103/