Open ghost opened 9 years ago
I personally do not use Storyboards/AutoLayout, so if someone else would like to supply an example, that would be great!
Here's an example of doing this with AutoLayout:
Say you have a constraint fixing a UIView to the bottom of the screen, and we want this view to 'follow' the keyboard as we drag it down:
[self.view addKeyboardPanningWithFrameBasedActionHandler:nil
constraintBasedActionHandler:^(CGRect keyboardFrameInView, BOOL opening, BOOL closing)
{
NSLog(@"constraint handler: %f", keyboardFrameInView.origin.y);
__typeof__(self) strongSelf = weakSelf;
if (strongSelf)
{
strongSelf.inputFieldBottomConstraint.constant = strongSelf.view.frame.size.height - keyboardFrameInView.origin.y;
[strongSelf.view layoutIfNeeded];
}
}];
If it doesn't work its probably a good idea to test if the Autolayout constraint is correct.
Trying to use this control in a new app that requires Storyboard/Autolayout. I see you added a 2nd block 'constraintBasedActionHandler' to each method, but I don't see any examples on how to properly use it.
I tried this but the message input view I have never moves:
It does work when I set the frame manually and not use the auto layout constraint, but I am having to many issues with different devices and am trying to steer clear of setting frames directly.