模态视图控制器大小与主 - 细节控制器 [英] Modal view controller size with master-detail controller

查看:108
本文介绍了模态视图控制器大小与主 - 细节控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程式有一个拆分的主 - 细节界面:当用户点击屏幕细节一侧的特定按钮时,我使用 UIModalTransitionStyleFlipHorizo​​ntal modalTransitionStyle ,以便我可以模拟地呈现一个新的控制器,让它看起来好像细节面板已经翻转到新的界面。

My app has a split master-detail interface: when the user hits a particular button in the detail side of the screen, I use a UIModalTransitionStyleFlipHorizontal modalTransitionStyle so that I can just present a new controller modally and have it appear as if the details panel has "flipped" to the new interface.

虽然这在iPhone上正常工作,当我在iPad上尝试它时,新的模态控制器从屏幕的细节侧翻转,但在动画结束时,它覆盖整个屏幕。

While this works fine on the iPhone, when I try it on the iPad, the new modal controller flips from the details side of the screen but at the end of the animation, it's covering the entire screen.

如何使控制器只在屏幕的细节面内翻转?

How can I cause the controller to flip only within the details side of the screen?

推荐答案

如果你还没有想到这一点,你是最大的方式在那里。您需要定义当前上下文的模态视图的演示文稿上下文,以便它只在详细视图中操作,而不是在整个超级视图上操作。

if you haven't figured this out yet, you are most of the way there. You need to define the presentation context of the modal view for "current context" so that it only operates in the detail view and not on the entire superview.

最简单的方法是使用segue设置故事板中的视图。在IB中,创建新的视图控制器,添加一个segue并编辑segue行,通过给它一个名称flipper,设置为模态,设置为翻转,并将其设置为当前上下文。

the simplest way to do this is to setup the view in storyboard with a segue. In IB, create the new view controller, add a segue and edit the segue line by giving it a name "flipper", set it to modal, set it to flip and set it's presentation to "current context".

一旦设置了这些属性,你只需要连接到视图控制器,但是从细节视图控制器启动它:

Once those properties are set, you can just segue to the view controller - but initiate it from the detail view controller like this:

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

如果你需要在代码中进行转换,它看起来像这样:

If you need to do the transition in code it would look something like this:

UIViewController *abc = [self.storyboard instantiateViewControllerWithIdentifier:@"flipper"];
[abc setModalPresentationStyle:UIModalPresentationCurrentContext];
[abc setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentViewController:abc animated:YES completion:nil];

这篇关于模态视图控制器大小与主 - 细节控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆