Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIModalPresentationStyle.FormSheet Always full screen on iPad (SWIFT)

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.

like image 752
YogevSitton Avatar asked Aug 31 '14 07:08

YogevSitton


1 Answers

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.

like image 179
Mundi Avatar answered Sep 18 '22 04:09

Mundi