Closed Skornos closed 8 years ago
As you can see here: https://github.com/m1entus/MZFormSheetPresentationController/blob/master/MZFormSheetPresentationController/MZFormSheetPresentationController.m#L486 If you set frameConfigurationHandler then you are responsible for keyboard movement as well.
Thanks for your quick response. Would it be possible to adjust the library to pass the property keyboardVisible
to the frameConfigurationHandler
along with the self.presentedView
and formSheetRect
?
I think it makes sense because these properties are the ones which define how the frame should display and the frameConfigurationHandler
is called when the keyboard appears. Otherwise I would need to register for keyboard notifications which seems redundant if you are doing this in your code already.
Sure, that make sense, i also exposed isKeyboardVisible property in presentationController. Thanks.
I want to anchor the bottom of the form sheet to the top of the keyboard but don't know how to get the keyboard's frame (height specifically) without registering for notifications. Would it be possible to expose screenFrameWhenKeyboardVisible
too?
EDIT:
Sorry, looked into the code further and realized you're already including the offset in the formSheetRect
parameter.
formSheetController.presentationController?.movementActionWhenKeyboardAppears = .AlwaysAboveKeyboard
formSheetController.presentationController?.frameConfigurationHandler = { (view, formSheetRect, isKeyboardVisible) in
...
// add 20 to anchor frame to bottom because it's the default internal margin
if isKeyboardVisible {
return CGRectMake(0, formSheetRect.origin.y+20, width, height)
}
else {
return CGRectMake(0, 0, width, height)
}
}
anchors the form sheet to the keyboard when the keyboard appears.
New problem though, this is only true if the keyboard appears in the initial orientation that the form sheet was presented in. Presenting the sheet, rotating, and then opening the keyboard offsets the frame by an incorrect value, and rotating after presenting the keyboard breaks all of my form sheets subviews. Any ideas on how to fix this?
use MZFormSheetActionWhenKeyboardAppearsAboveKeyboard
for movementActionWhenKeyboardAppears
property on presentationController
I'm using .AlwaysAboveKeyboard
because my Form Sheet is full screen.
Here are a few screenshots of what I mean:
Present VC in landscape, open keyboard in landscape: (perfect!)
Present VC in landscape, open keyboard in portrait: (VC isn't moving up enough)
Present VC in portrait, open keyboard in landscape (VC is moving up too much)
What is the fixed for this ?
Hi,
I am using
frameConfigurationHandler
to align my presented view to the bottom of the screen like this:At the same time this view aligned to the bottom contains 2 input TextFields so I am also setting
movementActionWhenKeyboardAppears
The problem is that when I tap the textField the keyboard covers the whole bottom view which doesn't slide up. I suppose it is a conflict between setting my custom frame and displaying keyboard. Or am I doing something wrong?
Thanks :)