UIModalPresentationStyle.FormSheet Always full screen on iPad (SWIFT)
Asked Answered
U

1

8

I'm trying to translate some Objective-C code to SWIFT.

I'm loading a UIViewController as a Form Sheet. Here's the code in objective-c:

generalPopup.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
generalPopup.modalPresentationStyle = UIModalPresentationFormSheet;

Here's the code in Swift:

generalPopup.modalTransitionStyle = UIModalTransitionStyle.CoverVertical
generalPopup.modalPresentationStyle = UIModalPresentationStyle.FormSheet

In Objective-C the view is shown as a FormSheet. In swift, the CoverVertical is maintained, but the view takes the whole screen instead of being shown as FormSheet.

Just as a reminder, according to Apple a FormSheet is:

A view presentation style in which the width and height of the presented view are smaller than those of the screen and the view is centered onscreen. If the device is in a landscape orientation and the keyboard is visible, the position of the view is adjusted upward so the view remains visible. All uncovered areas are dimmed to prevent the user from interacting with them.

Unskillful answered 31/8, 2014 at 7:47 Comment(0)
J
1

Continuing your quote from the docs:

In a horizontally compact environment, this option behaves the same as UIModalPresentationFullScreen.

It seems you have a "horizontally compact environment". Check you storyboard settings in the swift project.

Jackelinejackelyn answered 31/8, 2014 at 9:46 Comment(3)
Where can I check this setting?Unskillful
Check the type of the segue if there is one in IB. Check the dimensions of the view controller and its view.Jackelinejackelyn
There is no segue. The calling ViewController is from a StoryBoard but the called (FormSheet) view controller uses a standalone XIBUnskillful

© 2022 - 2024 — McMap. All rights reserved.