10

I currently change the scrollview size when the keyboard is active. I also use arrows to allow the user to quickly move to the next textfield. My scrollRectToVisible is not working properly in the vertical direction. It moves horizontally properly. I have been having a issue with my decimal pad

2014-09-12 10:29:24.039 TS[1895:455658] Can't find keyplane that supports type 8 for keyboard iPhone-Portrait-DecimalPad; using 1425143906_Portrait_iPhone-Simple-Pad_Default

I also stepped through the following code.

- (void)keyboardDidShow:(NSNotification *)n {
// Find top of keyboard input view
CGRect keyboardRect = [[[n userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
keyboardRect = [self.view convertRect:keyboardRect fromView:nil];
CGFloat keyboardTop = keyboardRect.origin.y;

// Resize scroll view
CGRect newScrollViewFrame = CGRectMake(0, 0, self.view.bounds.size.width, keyboardTop);
newScrollViewFrame.size.height = keyboardTop - self.view.bounds.origin.y;
[self.scrollView setFrame:newScrollViewFrame];
}

I have noticed that the keyboardRect is 244 for my decimal pad and 207 for my default keyboard. I am not sure how to fix this. Also this issue has only popped up in iOS 8. My app did not have any trouble in iOS 7. Thanks for the help.

UPDATE: I have found that when a textfield is initially selected the scrollview moves appropriately. When you then select another textfield while the keyboard is up is when the issue occurs. It appears that the scrollview resets its size to the original dimensions. Why would this happen? Is there a way to stop this from happening?

jmr1706
  • 239
  • 2
  • 13
  • I was facing the same weird behavior while working with scorllview and autoresizing in ios 8.4 ,Xcode 6.4. A quick fix for this is to adjust the frame of your ScrollView in textField delegate Method -(void)textFieldDidEndEditing:(UITextField *)textField. – Irfan Gul Aug 25 '15 at 07:35

1 Answers1

0

1) issue

see this post: Xcode iOS 8 Keyboard types not supported

2) issue:

not sure what you mean. may be related to iOS 8 keyboard type change. And remember that rect includes whatever accessoryview you added.

3) additional issue in update section:

I encounter the same issue, and do figure out some clues.

I have a scroll view placed inside of viewcontroller.view, and a bunch of textfield inside of that scroll view. I do a scroll view frame resize on UIKeyboardDidShowNotification and UIKeyboardWillHideNotification. It works fine on iOS7, but on iOS8 the scrollview will silently resize back to normal size when you focus on another textfield (become first responder).

I took a further look into it. I have another page, which is created before iOS8 upgrade and still works perfectly fine using the same logic. But one difference is, in that page the scroll view is added programmatically, and this malfunctioning page it's auto layout (scrollview has all margin zero constraints regarding viewcontroller.view).

So I did a test, resize the frame and bound of viewcontroller.view on keyboardshow/hide, and the issue is gone. So I'm guessing iOS8 adds a whole page re-layout (re-calculate the constraints) on view first responder change.

Not sure what is the best solution. Will update this answer when I do figure out a better way to handler this issue.

Community
  • 1
  • 1
Perisheroy
  • 239
  • 4
  • 8
  • I could definitely see the issue being related to auto-layout. I haven't had a lot of time to test this lately. But I will try changing auto-layout and see what happens. Thanks – jmr1706 Oct 15 '14 at 18:12