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
974 stars 145 forks source link

Rotation issue. Happens starting from 2.0+. Reproducible on iOS 8&9 #33

Closed Austinate closed 8 years ago

Austinate commented 8 years ago

Hi :) unfortunately, i've faced small issue with your awesome library.

If MZFormSheetPresentationController is presenting any controller (in my case it's alert view), than origin of it's content view is calculated wrong during transition to another size/size class.

Steps:

  1. Launch sample project.
  2. Present popover
  3. Present alert
  4. Rotate to landscape (or you can present in landscape and rotate to portrait)
  5. Observer results

I see this results since MZFormSheet started to use UIPresentationController API. So here comes the question: is that me doing something wrong or we have a bug?

Thanks for help! Ping me if you will need additional info.

Sample code can be found here in master branch: https://github.com/Austinate/MZFormSheetIssueSample

Normal result: simulator screen shot 28 2015 11 45 43

Buggy result: simulator screen shot 28 2015 11 45 36

Austinate commented 8 years ago

I've made few debugging sessions and what i've found. In -(void)setupFormSheetViewControllerFrame happens this:

1) Form sheet is presenting another controller:

PresentedView before transition: {{37.5, 258.5}, {300, 150}}
formSheetViewControllerFrame: {{183.5, 112.5}, {300, 150}}
PresentedView after transition{{37.5, 258.5}, {300, 150}}

2) Form sheet doesn't present anything:

PresentedView before transition: {{37.5, 258.5}, {300, 150}}
formSheetViewControllerFrame: {{183.5, 112.5}, {300, 150}}
PresentedView after transition{{183.5, 112.5}, {300, 150}}

So it looks like self.presentedView.frame = [self formSheetViewControllerFrame]; doesn't affect actual presentedView frame if controller is presenting another controller.

m1entus commented 8 years ago

This can be mixed issue UIAlertController and MZFormSheetPresentation i will need to check, but in the meantime check this one: https://github.com/m1entus/MZFormSheetPresentationController/blob/master/MZFormSheetPresentationController/MZFormSheetPresentationViewController.m#L50

Austinate commented 8 years ago

Thanks, now i see why frame wasn't set. But, honestly, i can't get what's the purpose of ' (self.viewController.presentedViewController.modalPresentationStyle != UIModalPresentationOverFullScreen || self.viewController.modalPresentationStyle != UIModalPresentationCurrentContext || self.viewController.modalPresentationStyle != UIModalPresentationCustom)' check?

In other words, which modalPresentationStyle should i use so this will work? (in case of using any other UIViewController of course, because i don't think changing modalPresentationStyle for UIAlertController will affect anything)

m1entus commented 8 years ago

Because if the modalPresentationStyle is UIModalPresentationFullScreen which is by default, there is a problem that the size of formSheet is resized to full screen, i will think about some workaround about it.

Austinate commented 8 years ago

Thanks for fast reply, i think right now i'll just switch to 1.1.3 version. If i can help with something — feel free to ask. And again, thanks for help!

m1entus commented 8 years ago

Sorry, that was bug from my side, it was fixed in new version which is also available on cocoapods. Thanks for issue!