m1entus / MZFormSheetPresentationController

MZFormSheetPresentationController provides an alternative to the native iOS UIModalPresentationFormSheet, adding support for iPhone and additional opportunities to setup UIPresentationController size and feel form sheet.
MIT License
973 stars 146 forks source link

Auto Layout Issue #59

Closed jeffblake closed 8 years ago

jeffblake commented 8 years ago

Hi,

I'm using Storyboard. I've created 2 container views, a couple of toolbars, etc, and when I present it with MZFormSheet, I get the following auto layout issues:

screen shot 2016-02-11 at 8 58 05 pm

screen shot 2016-02-11 at 8 58 16 pm

If I take out MZFormSheet, and present it regularly, it works just fine. I tried doing the symbolic breakpoint to maybe pinpoint it in this library, but it only breaks somewhere in creating the storyboard.

Code:

+ (MZFormSheetPresentationViewController *)orderSummaryController:(Order *)order
{

    OrderCheckoutController *controller = [[UIStoryboard storyboardWithName:@"OrderCheckoutStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:@"checkout"];

    controller.order = order;

    MZFormSheetContentSizingNavigationController *navigationController = [[MZFormSheetContentSizingNavigationController alloc] initWithRootViewController:controller];

    MZFormSheetPresentationViewController *formSheetController = [[MZFormSheetPresentationViewController alloc] initWithContentViewController:navigationController];

    formSheetController.presentationController.shouldDismissOnBackgroundViewTap = NO;
    formSheetController.presentationController.movementActionWhenKeyboardAppears = MZFormSheetActionWhenKeyboardAppearsMoveToTop;
    formSheetController.presentationController.contentViewSize = controller.preferredContentSize;
    formSheetController.contentViewControllerTransitionStyle = MZFormSheetPresentationTransitionStyleSlideFromBottom;

    return formSheetController;
}

And in my content controller:

- (BOOL)shouldUseContentViewFrameForPresentationController:(MZFormSheetPresentationController *)presentationController
{
    return YES;
}

- (CGRect)contentViewFrameForPresentationController:(MZFormSheetPresentationController *)presentationController currentFrame:(CGRect)currentFrame
{
    CGFloat preferredHeight = self.preferredContentSize.height;
    CGFloat height;

    if (self.paymentStepController.addPaymentController.creditCardController.shouldShowCardIOView) {
        height = preferredHeight + 240;
    } else {
        height = preferredHeight;
    }

    currentFrame.size.height = height;

    return currentFrame;
}
m1entus commented 8 years ago

You are setting wrong contraints if you are using resizing between them ther are exists until transition is finished so you must be carefound with constraints sticked to the bottom. This is not issue in library but how it works and constraints when resizing

jeffblake commented 8 years ago

Hi, thanks for the reply. I'm using pretty standard constraints - and the interface builder is not complaining. What do you see wrong with this? I love this library (seems very well made) and prefer it over the standard FormSheet due to the movement to the top when the keyboard appears. Hopefully I can get it to work.

screen shot 2016-02-12 at 9 53 48 am

m1entus commented 8 years ago

Check how the constraints are set in example project when there is resizing animation between view controllers. Bottom Layout Guide is removed.

jeffblake commented 8 years ago

Perfect, it's working now. Thank you

m1entus commented 8 years ago

Cool :)