UITextView inputAccessoryView overlaps top of keyboard in iOS 8

1.1k views Asked by At

I have a pretty vanilla inputAccessoryView toolbar for some UITextView fields. Previous, Next, and Done buttons. I put them in a UIViewController class, and I assigned them to the UITextFields like this:

self.outPlayerOneTextField.inputAccessoryView = myAccessoryVc.view;

This worked great in iOS 7. With iOS 8, it now overlaps the top of the keyboard, like so:

accessory toolbar overlapping top of keyboard in ios8

Any pointers on what changed? Or perhaps wrapping it in a view controller wasn't a good thing to do?

1

There are 1 answers

0
Ben On BEST ANSWER

I had the same thing happen to me. The frame wasn't being set automatically by constraints for me. To fix it, I set the frame manually before setting the inputAccessoryView like this:

CGSize rect=[view systemLayoutSizeFittingSize:CGSizeMake(0, 0)];
view.frame=CGRectMake(0, 0, rect.width, rect.height);

Or if you use Objective C++ you can simplify it like this:

view.frame={{0,0},[view systemLayoutSizeFittingSize:{0,0}]};