Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Formsheet ios 8 constraints are same as iphones constraints

I have this problem where formsheet in ios 8 is taking the constraints set for "compact - width regular -height" (that is all iPhones constraints) instead of "any- any" or "regular -width regular -height". I have two different design for iPhone and iPad since the formsheet is consuming iPhones constraint iam not able to achieve the same. Any help on this would be aprreciatd

like image 932
varun thomas Avatar asked Nov 27 '14 03:11

varun thomas


1 Answers

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:^{}];
}
like image 67
Pierre Avatar answered Nov 15 '22 23:11

Pierre