Я пытаюсь изменить размер UITExtView, когда показывает клавиатура. На iPhone он работает красиво. Когда система отправляет уведомление клавиатуры, вид текста изменяется. Когда это сделано редактирование, я изменил его, чтобы заполнить начальное пространство. (Да, я предполагаю, что клавиатура ушла, когда редактирование останавливается. Я должен изменить это. Однако я не думаю, что это моя проблема.)
Когда я изменил размер текстового просмотра на iPad, кадр изменяется правильно, Но приложение, похоже, сбрасывает значение Y кадра до нуля. Вот мой код:
- (void) keyboardDidShowWithNotification:(NSNotification *)aNotification{
//
// If the content view being edited
// then show shrink it to fit above the keyboard.
//
if ([self.contentTextView isFirstResponder]) {
//
// Grab the keyboard size "meta data"
//
NSDictionary *info = [aNotification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
//
// Calculate the amount of the view that the keyboard hides.
//
// Here we do some confusing math voodoo.
//
// Get the bottom of the screen, subtract that
// from the keyboard height, then take the
// difference and set that as the bottom inset
// of the content text view.
//
float screenHeightMinusBottom = self.contentTextView.frame.size.height + self.contentTextView.frame.origin.y;
float heightOfBottom = self.view.frame.size.height - screenHeightMinusBottom;
float insetAmount = kbSize.height - heightOfBottom;
//
// Don't stretch the text to reach the keyboard if it's shorter.
//
if (insetAmount < 0) {
return;
}
self.keyboardOverlapPortrait = insetAmount;
float initialOriginX = self.contentTextView.frame.origin.x;
float initialOriginY = self.contentTextView.frame.origin.y;
[self.contentTextView setFrame:CGRectMake(initialOriginX, initialOriginY, self.contentTextView.frame.size.width, self.contentTextView.frame.size.height-insetAmount)];
}
Почему эта работа на iPhone, а не работает на iPad? Кроме того, могут ли мои автосалонные маски сделать неожиданное изменение?