ViewController canBecomeFirstResponder iOS 8

369 views Asked by At

I have a VC that has an inputAccessoryView that is used to display a textfield (much like the messages app). When I push this view onto the navigation stack everything works fine and by that I mean that the tableview adjusts its insets to make sure nothing scrolls underneath that accessory view. However, if from that view I push on another instance of the same view controller class the insets will not be adjusted and the scrolling of the table will be behind the accessory view.

This issue is seen in iOS 8 only. The other interesting thing about this is that if you then click in the accessory view to open the keyboard the insets are adjusted properly for the keyboard being visible and again when it's hidden.

Also if you don't click the text field to fix the issue and hit back the previous VC is broken as well.

I'm fairly certain based on the information above that this is an iOS 8 bug. I'm hoping someone has seen this and come up with semi reasonable fix.

1

There are 1 answers

0
Steve On BEST ANSWER

Nasty solution but a solution nonetheless:

    - (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self.inputAccessoryView.inputAccessoryTextField becomeFirstResponder];
        [self.inputAccessoryView.inputAccessoryTextField resignFirstResponder];
    });
}

This allows the view to redraw the insets