Formsheet ios 8 constraints are same as iphones constraints

Another solution is to use vc.presentationController.overrideTraitCollection

    // in landscape mode, we want the horizontal traits to be the same as the main screen
    if ( UIScreen.mainScreen.traitCollection.horizontalSizeClass ==  UIUserInterfaceSizeClassRegular){

        //if you use UIModalPresentationFormSheet, the traits horizontal will be compact , even on iPad, so we have tell the presentationcontroller to force the horizontaltraits to regular
        vc.modalPresentationStyle=UIModalPresentationFormSheet;
        vc.presentationController.overrideTraitCollection = [UITraitCollection traitCollectionWithHorizontalSizeClass:UIUserInterfaceSizeClassRegular ];
        [_rootViewController presentViewController:vc animated:true completion:^{}];
}

From the UIViewController class reference:

In a horizontally regular environment, a presentation style that displays the content centered in the screen. The width and height of the content area are smaller than the screen size and a dimming view is placed underneath the content. If the device is in a landscape orientation and the keyboard is visible, the position of the view is adjusted upward so that the view remains visible. All uncovered areas are dimmed to prevent the user from interacting with them.

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

Because the form sheet presentation on iPad is compact width and regular height, these are the values you'll get when you present a form sheet.


If you don't want the default size classes you can override them.

If your view controller is a child view controller of another, you can use setOverrideTraitCollection(_:forChildViewController:) and override the size class constraints for the child controller.

If your view controller is NOT a child view controller, you're not really supposed to change the trait collection, but you can do it using this hack.


The best solution would be to design your view controller to look appropriate in the default (correct) size constraints applied for a form sheet view controller presentation. You can usually do this by avoiding setting width constraints and only setting leading and trailing constraints.