IOS 8 switch apps cause keyboard to tilt, pointInside behaves differently

A very strange iOS 8 bug.

  • My iOS app has UIViewController

    withUITextfield

  • When in edit mode they need more help dropping the keyboard when pressed outside
  • I fixed it in iOS 7 by adding something like this in each VC

    - (void)keyboardWasShown:(NSNotification*)notification
    {
        id responder = [UIResponder currentFirstResponder];
        if ([responder isKindOfClass:[UITextField class]]) {
            _textFieldResponder = responder;
        }
        else {
            _textFieldResponder = nil;
        }
    }
    
    - (void)keyboardWillHide:(NSNotification*)notification
    {
        _textFieldResponder = nil;
    }
    
    - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event usualReturn:(BOOL)rv
    {
        if (_textFieldResponder) {
            CGPoint pvIn = [_textFieldResponder convertPoint:point fromView:self.view];
            if (!CGRectContainsPoint(_textFieldResponder.bounds, pvIn)) {
                [UIResponder resignAnyFirstResponder];
            }
        }
        return rv;
    }
    
          

and in viewDidLoad from VC

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasShown:) name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];

      

This works great in iOS 7. Now in iOS 8 this also works great ...

UNTIL!

It works fine until the 4-finger user moves to another app and then comes back. Then, when uitextfield enters edit mode, pressing the keyboard will send a touch directly to UIVew

behind it, causing pointInside

and causing the keyboard to tilt.

Could you please help me understand what is happening in the world (in iOS 8) when exiting an application that will cause it to behave so weird? Thank you so much for your help.

+3
objective-c uitextfield ios8


source to share


No one has answered this question yet

See similar questions:

7
hitTest fires while listening to UIKeyboard

or similar:

422
iOS - Disable keyboard on touch outside of UITextField
372
An easy way to remove the keyboard?
361
How to remove keyboard for UITextView with return key?
211
iPad keyboard will not be canceled if the modal style of the ViewController's presentation is UIModalPresentationFormSheet
12
When to use colon with @selector
1
NSNotification issue for textbox and textbox
1
Xcode - embed network error alerts in my application? Can't get it to work?
1
Scroll view for multiple text fields not working
0
The specific expression in the if condition causes a 7 second delay in execution
0
Changing views keeps giving me an attempt to represent vc1 to vc whose view is not in the window hierarchy



All Articles
Loading...
X
Show
Funny
Dev
Pics