martinjuhasz / MJPopupViewController

A UIViewController Category to display a ViewController as a popup with different transition effects.
MIT License
964 stars 220 forks source link

UITextfield in MJPop #5

Open PaterB opened 12 years ago

PaterB commented 12 years ago

When I have a textfield in the Pop, the keyboard will block my MJPop, how can i make it move up automatically ?

cmelbye commented 12 years ago

I'm having this issue too. I may just modify the code myself to position the popup so that the keyboard doesn't block it.

inb4ohnoes commented 12 years ago

I fixed this by moving the entire view up by first adding

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
    [self becomeFirstResponder];

to viewDIdLoad then

- (void)keyboardWillShow: (NSNotification*) aNotification;
{
        [UIView animateWithDuration:0.35
                              delay:0.0
                            options:UIViewAnimationCurveEaseOut
                         animations:^(void){
                             self.view.transform = CGAffineTransformMakeTranslation(0, -85);
                         }
                         completion:^(BOOL finished) {}];
}

and likewise for keyboardWillHide

Hope this helps!