Reputation: 353
I've got stuck on resolving why does keyboard in my app appears on screen partially or doesn't appears at all. It's just a simple view controller presented with;
[self presentViewController:vc_browser animated:YES completion:^{}];
The first time I Present it ,all works normal.Then I dismiss it with
[self dismissModalViewControllerAnimated:NO];
and when presenting again(and further) this $#%! happens.Loggin the keyboard frame from notification gives
2012-12-30 00:40:21.618 test[12080:907] keyboard frame raw {{160, 443}, {0, 44}}
2012-12-30 00:40:21.619 test[12080:907] keyboard frame converted {{320, 886}, {0, 88}}
2012-12-30 00:40:21.836 test[12080:907] keyboard frame raw {{0, 524}, {320, 44}}
2012-12-30 00:40:21.837 test[12080:907] keyboard frame converted {{0, 1048}, {640, 88}}
in the picture below the focus is inside the webView (actually google search field)
if i move focus to the textfield above the keyboard rect logged is {{inf, inf}, {0, 0}}
viewWillAppear and viewDidAppear is not implemented
the presented view controller is loaded this way
_vc = [[VC alloc] initWithNibName:@"VC" bundle:nil];
I've tried loading this view controller from other xib or other storyboard, but problem is stil there.
Any help resolving this would be great.Thanks.
https://i.sstatic.net/xBNZt.png
cant post an image with rep < 10
Upvotes: 4
Views: 609
Reputation: 454
I’m also having this same issue. I don’t know how to post a comment to your question (I’m still new to Stack Overflow) so I’m providing what I have found out so far as a partial answer. Still researching the full solution.
Using Xcode 4.5.1 and my app uses iOS 6. It’s a Universal app using Core Data and the iPhone side works fine. The iPad side is a Split View. From the Detail View Controller the user can open a full window over the Split View to display a photo. Dismissing the photo view returns you to the Split View.
Code below on how the photo browser is called and dismissed.
[self presentViewController:photoBrowser animated:YES completion:nil];
[self dismissViewControllerAnimated:YES completion:nil];
After the photo view is dismisses is when I have the keyboard issue.
Symptoms: Subsequent views with UITextFields or UITextViews no longer automatically display the keyboard or the keyboard shows up only partially, as in your photo example. I use becomeFirstResponder to bring up the keyboard.
[self.noteEdit becomeFirstResponder];
What’s also odd is if I touch into any UITextField, then all the text fields in that view disappear.
I have opened an Apple Technical Support Incident (TSI) for this issue. Here was their reply on Oct 12, 2012.
I want to give you an update on your incident. Thank you for sending in your code and the sample database. I have been able to reproduce the issue. It turns out, the text fields disappearing in the detail view controller is a result of the keyboard returning invalid data for UIKeyboardFrameEndUserInfoKey causing your code to set the scroll view frame to an invalid size. I am continuing to search for the root cause of this unexpected keyboard behavior and write back as soon as I have an answer.
I verified his reply by displaying the UIKeyboardFrameEndUserInfoKey userInfo values.
NSLog(@"keyboardEndFrame orig.x=%f orig.y=%f size.w=%f, size.h=%f",
keyboardEndFrame.origin.x, keyboardEndFrame.origin.y, keyboardEndFrame.size.width, keyboardEndFrame.size.height);
And sure enough, the values for both origin x and y were "inf". The size values were set to zero.
Now I just need to know the cause of all this. Still researching but I'll keep you posted of any Apple's reply. This one has me stumped so far.
PS... My app (iPhone & iPad) was working fine in iOS 5.
Update - Oct 17, 2012:
The cause of my keyboard problems was due to my errors with implementing the new way iOS 6 handles Orientation. I had subclassed my split view controller to include the following:
- (NSUInteger)supportedInterfaceOrientations {
return [[self splitViewController] supportedInterfaceOrientations];}
The corrected code is:
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortrait;}
This was pointed out to me when my Apple Technical Support Incident replied with the following:
I've tracked down the root cause of your keyboard troubles. In SplitController.m, the method supportedInterfaceOrientations calls: [[self splitViewController] supportedInterfaceOrientations]; and returns the value received. However, the splitViewController property of a split view controller is nil as split view controllers insider other split view controllers is not allowed. Thus, the returned value is 0, which is an invalid orientation mask.
My app supports different orientation types based on what view is on top of the stack but I had coded the Split View Controller incorrectly.
Apple Technical Support group helped me greatly. Hope this info helps you.
Cheers!
Upvotes: 4