1

I created a new project just to test this.

Demo

Create a Master-Detail project. On the Main_iPhone.storyboard:

  1. Change the prototype cell style to Custom.
  2. Make the Table View's row height 504 to fill the whole screen with each cell.
  3. Put a UITextView filling the bottom half of the prototype cell.
  4. In MasterViewController.m, Remove this line from cellForRowAtIndexPath:
cell.textLabel.text = [object description];

Run the project and add some cells. Then tap on the text view to edit the content.

Description of the problem

Every time I tap on the Text View, the cell scrolls up to reveal the text view momentarily (as it should), and then scrolls back down so that the top of the cell is visible, which hides the text view behind the keyboard.

Video

This question has a video of the problem: UITableView in iOS 7 not scrolling to correct location when editing UITextView in cell

Question

What could be causing this? Can you find any Apple documentation that talks about how a UITableViewController handles keyboards?

Community
  • 1
  • 1
dmzza
  • 2,308
  • 1
  • 21
  • 33
  • And finally, how did you solve this problem? – PatrickV Nov 19 '15 at 20:47
  • It was too long ago to remember now, but I would guess that I just subclassed a `UIViewController` and put a `UITableView` in it with the `VC` as its data source and delegate. – dmzza Nov 19 '15 at 22:36

1 Answers1

-1

I was able to hack around this problem using TPKeyboardAvoidingTableView and adding this to my UITableViewController subclass:

- (void)viewWillAppear:(BOOL)animated
{
    // Removed to avoid default tableview scrolling behavior when the keyboard appears
    //[super viewWillAppear:animated]; 
}

Just using TPKeyboardAvoidingTableView alone was not enough, because the default behavior from the UITableViewController would override it. Preventing viewWillAppear from running was the only way I could find to stop that behavior. But I dislike this solution because I don't know what else I might be loosing.

dmzza
  • 2,308
  • 1
  • 21
  • 33
  • Preventing a call to `super` can't be an acceptable solution. Why don't you, instead of subclassing `UITableViewController` just subclass `UIViewController` and set it up as a TableView delegate/datasource? – nhgrif Apr 10 '14 at 23:06
  • I know how to do this, but won't I be loosing some kind of functionality this way? – dmzza Apr 10 '14 at 23:10
  • No. None that I can think of. There are things that `UITableViewController` will do automatically, but nothing that you can't implement yourself. – nhgrif Apr 10 '14 at 23:14
  • That's just the problem... I don't know what those things are. I can't even find documentation anywhere stating that a UITableViewController automatically scrolls when the keyboard appears. – dmzza Apr 10 '14 at 23:15
  • Potentially missing some functionality... then going back and implementing it later when you find out you were missing the functionality... this is MILES better than a fix that relies on preventing a super class from doing something. – nhgrif Apr 10 '14 at 23:17