Closed Joker666 closed 8 years ago
@phatmann Could you add some info about it?
@Joker666 I was able to puzzle this out. You need to add <MZFormSheetPresentationContentSizing>
to each of your view controllers that you display in the form sheet and then implement the protocol:
- (BOOL)shouldUseContentViewFrameForPresentationController:(MZFormSheetPresentationController *)presentationController {
return YES;
}
- (CGRect)contentViewFrameForPresentationController:(MZFormSheetPresentationController *)presentationController currentFrame:(CGRect)currentFrame {
currentFrame.size.width = _modalContentSize.width;
currentFrame.size.height = _modalContentSize.height;
return currentFrame;
}
_modalContentSize is my own property-- you can return a fixed value or whatever.
@eliburke tried it, didn't seem to work for me.
Hmm... maybe you need to use a MZFormSheetContentSizingNavigationController? Sorry I fiddled around with this a bit but didn't document which steps were part of the solution. Try putting breakpoints into shouldUseContentViewFrameForPresentationController and make sure they are being called. Take a look at MZFormSheetPresentationController.m at modifiedContentViewFrameForFrame which is where your view controllers' size is checked. Another possibility: all of your view controllers must implement the protocol, not just those that are pushed from the primary.
From the README:
formSheetController.presentationController?.contentViewSize = CGSizeMake(250, 250) // or pass in UILayoutFittingCompressedSize to size automatically with auto-layout
So pass UILayoutFittingCompressedSize
into contentViewSize
and auto-layout will be used to size the dialog.
UILayoutFittingCompressedSize
doesn't work, breaks the layout, it needs height externally.
When I first tried this option, my height did not work either. You have to make sure all of your contentHugging and contentCompressed priorities are set correctly, and you need to make sure that you have at least one view anchored to the bottom. If you get constraint conflicts before the sizing takes place, you might have to reduce the bottom constraint to 900 priority.
I see in the first demo image, two view controllers have different content size. I presented my first view controller with formSheetPresentationController, but I need to change the content size for the second view controller that I push from first view controller. The update for 2.x changelog says
but it's not documented anywhere how to achieve that. It'll be very helpful if you document that.