Si dovrebbe usare il keyboardWillShow
: notifica per regolare altre cornici di viste.
Una notifica viene inviata a keyboardWillShow
: non solo su becomeFirstResponder
per un testoView/Field ma anche quando l'utente mostra/nasconde la tastiera di tipo rapido.
volta il keyboardWillShow
: segnalazione è stata pubblicata, il telaio della tastiera può essere catturato dal UIKeyboardFrameEndUserInfoKey
nell'oggetto notifica.
Un esempio di textView
che regola il suo telaio in base alla tastiera:
- (void)keyboardWillShow:(NSNotification *)notification
{
CGRect keyboardRect = [[[notification userInfo] valueForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
NSTimeInterval duration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
UIViewAnimationCurve curve = [[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue];
[UIView animateWithDuration:duration animations:^{
[UIView setAnimationCurve:curve];
self.textViewVisualEffectView.frame = CGRectMake(self.textViewVisualEffectView.origin.x, self.view.height - keyboardRect.size.height - self.textViewVisualEffectView.height, self.textViewVisualEffectView.width, self.textViewVisualEffectView.height);
} completion:^(BOOL finished) {
}];
}
Date un'occhiata a mia soluzione nel link: http://stackoverflow.com/questions/26213681/ios-8- tastiera-hides-my-textview/26226732 # 26226732 –