开发者

iPad Modal UIViewControllers position

开发者 https://www.devze.com 2023-03-22 16:34 出处:网络
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.

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


The modalPresentationStyle is what controls that. You've set it to UIModalPresentationStylePageSheet, 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消