In iOS7 self.keyboardActiveInput results in EXC_BAD_ACCESS for a UITextView
Closed this issue · 2 comments
I am using a UITextView in one of my App's controllers which doesn't rely on the functionality provided by DAKeyboardControl.
When the view containing the UITextView is presented I force the keyboard to appear right away by [self.textView becomeFirstResponder] in viewWillAppear.
This works fine in iOS5 and iOS6. However, in iOS7 this results in a crash which I traced to:
- (void)inputKeyboardDidShow, self.keyboardActiveInput results in EXC_BAD_ACCESS
Some debugging shows that keyboardActiveInput has a stale value.
I have two workarounds for this issue:
- call becomeFirstResponder in viewDidAppear
- the following code in viewWillAppear
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
dispatch_async(dispatch_get_main_queue(), ^{
[self.textView becomeFirstResponder];
});
}
else {
[self.textView becomeFirstResponder];
}
Both solutions work with the caveat that the keyboard does not appear right away which is not desirable. This appears to be an Apple issue but I am letting you know in case you have some insight which would cause this problem in iOS7. Note that if I exclude DAKeyboardControl support from my App which I can do through a #define, the problem does not surface at all.
My apologies in advance if this is a duplicate issue or ignorance on my part.
Best regards,
Sergio
I am experiencing the same crash on 2.3.0 but your workaround doesn't seem to work for me
edit: Fixed it by doing this:
-(void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
[self.view removeKeyboardControl];
}
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.view addKeyboardPanningWithActionHandler:^(CGRect keyboardFrameInView) {
...
Clearly a problem in my code. Thanks for your input Chris.