Search code examples
iosipaduisplitviewcontrollermodalviewcontrolleruimodalpresentationstyle

iPad Modal UIViewControllers position


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


Solution

  • 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.