У меня есть текстовое представление (nib-файл) с UITextView, максимизирующим весь вид.
Когда я когда-либо помещаю контроллер представления в навигационный контроллер, я загружаю клавиатуру в методе viewDidLoad представления текста.*
Моя проблема в том, что когда я пишу текст, в котором больше строк, чем места, текст находится за клавиатурой.Я следовал за sampe от Apple здесь .
Если я регистрирую "newTextViewFrame", это НЕДЕЙСТВИТЕЛЬНО.но если я отлаживаю вещь, у нее есть хорошее значение.Даже если я жестко закодирую его, размер UITextView не изменится.
Вот мой код:
- (void)keyboardWillShow:(NSNotification *)notification {
/*
Reduce the size of the text view so that it's not obscured by the keyboard.
Animate the resize so that it's in sync with the appearance of the keyboard.
*/
NSDictionary *userInfo = [notification userInfo];
// Get the origin of the keyboard when it's displayed.
NSValue* aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
// Get the top of the keyboard as the y coordinate of its origin in self's view's coordinate system. The bottom of the text view's frame should align with the top of the keyboard's final position.
CGRect keyboardRect = [aValue CGRectValue];
keyboardRect = [self.view convertRect:keyboardRect fromView:nil];
CGFloat keyboardTop = keyboardRect.origin.y;
CGRect newTextViewFrame = self.view.bounds;
newTextViewFrame.size.height = keyboardTop; - (self.view.bounds.origin.y);
// Get the duration of the animation.
NSValue *animationDurationValue = [userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey];
NSTimeInterval animationDuration;
[animationDurationValue getValue:&animationDuration];
// Animate the resize of the text view's frame in sync with the keyboard's appearance.
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:animationDuration];
createListingTextView.frame = newTextViewFrame;
[UIView commitAnimations];
NSLog(@"Textview resized: %@", newTextViewFrame);
}
Моя задача проста: реализовать представление с помощью UITextViewи клавиатура открывается и прокручивает UITextView, когда текст превышает.
Пожалуйста, совет ...