iPad Modal UIViewControllers 位置
如何以模态方式将此 ViewController 放置在详细信息视图上?我希望它右对齐,这样您就可以看到导航部分变灰。
[self.window addSubview:self.splitViewController.view];
MyModalViewController *modalvc= [MyModalViewController new]; //brevity
modalvc.modalInPopover = YES;
modalvc.modalPresentationStyle = UIModalPresentationStylePageSheet;
modalvc.view.autoresizeMask = UIViewAutoresizeFlexibleRightMargin;
[self.splitViewController presentModalView:modalvc animated:NO];
[self.window makeKeyAndVisible];
我还检查了 MyModalViewController 是否设置了视图蒙版,但我没有,也没有从笔尖获取魔法值。
调整当前帧之前的帧(使用 modalvc.view.frame)没有任何作用。
在现在之后调整框架似乎会产生疯狂的结果,我只需要它在横向上有一半宽度......纵向是正常行为。
编辑
图片让人们感到困惑,所以我把它拿出来,我不希望模式视图是屏幕的大小,我想保留它 UIModalPresentationStylePageSheet 但将其 ORIGIN 向右移动,以便它覆盖横向的详细视图部分
How do I position this ViewController over the detail view modally? I want it to be right aligned so you can see the navigation portion greyed out.
[self.window addSubview:self.splitViewController.view];
MyModalViewController *modalvc= [MyModalViewController new]; //brevity
modalvc.modalInPopover = YES;
modalvc.modalPresentationStyle = UIModalPresentationStylePageSheet;
modalvc.view.autoresizeMask = UIViewAutoresizeFlexibleRightMargin;
[self.splitViewController presentModalView:modalvc animated:NO];
[self.window makeKeyAndVisible];
I also checked in MyModalViewController if im setting the views mask and I am not, nor is it getting magic values from a Nib.
Adjusting the frame before the present (using modalvc.view.frame) does nothing.
Adjusting the frame after the present seems to yield crazy results, and I only really need it to be half a width over in landscape... portrait is normal behavior.
edit
the picture confused people so I took it out, I dont want the modal view to be the size of the screen, I want to keep it UIModalPresentationStylePageSheet but have its ORIGIN moved right so that it covers the detail view portion in landscape
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
modalPresentationStyle
是控制它的东西。您已将其设置为 UIModalPresentationStylePageSheet,它将高度设置为屏幕的高度,将宽度设置为纵向屏幕的宽度,与屏幕截图中的完全相同。我认为在横向中获得全宽的唯一方法是使用 UIModalPresentationFullScreen 。有关更多信息,请参阅 UIViewController 参考信息。
The
modalPresentationStyle
is what controls that. You've set it toUIModalPresentationStylePageSheet
, which sets the height to the height of the screen, and the width to to the width of the screen in portrait orientation, exactly as in your screenshot.I think the only way to get full width in landscape is to use
UIModalPresentationFullScreen
. See the UIViewController reference for more info.我遇到了类似的问题,最终我使用了一个自定义视图控制器,该控制器使用背景半透明视图和前景不透明视图,我可以通过操纵其框架将其放置在我想要的任何位置。它作为视频和图像的灯箱很有用。
I had a similar problem, and I ended up using a custom view controller that uses a background translucent view and a foreground opaque view that I am able to position anywhere I want by manipulating its frame. It's useful as a lightbox for videos and images.