2

I have a UITableView and its UITableViewCells can independently change their sizes via the function tableView:heightForRowAtIndexPath. They store UIImages of varying sizes. When I tap an image the keyboard is shown (lets say it is for tagging the images).

When I have, lets say, 3 cells (images) with a total height of 1 pixel less than the screen size it is all good. The keyboard is shown and I can scroll to see all the cells (images).

But when I add one more, pushing the total size to be more than the screen, it all breaks. The keyboard seems to be shown (I have an extra button on top, making it some pixels higher than the original keyboard, that is shown). But I cannot write anything. The button on top of the keyboard is to resign the keyboard, and it does not work. It is kind of stuck.

The project can be downloaded here:https://github.com/TokyoBirdy/cecilia/tree/master/Test (excuse the messy code)

jszumski
  • 7,430
  • 11
  • 40
  • 53
Cecilia Humlelu
  • 360
  • 2
  • 5
  • Take a look at these two and see if any of them will help your problem http://stackoverflow.com/questions/1842560/uitableview-wont-scroll-after-editing-view-frame-and-origin http://stackoverflow.com/questions/594181/uitableview-and-keyboard-scrolling-issue – Udrian Oct 03 '12 at 11:55

1 Answers1

0

I was able to solve my problem of the locked scrolling by removing the code that edits the view's origin. In addition, I implemented scrolling to the bottom cell by using the tableview's contentSize property in my calculations.

-(void) keyboardWillShow:(NSNotification *)note
{

  if(!isKeyboardShowing)
    {
    isKeyboardShowing = YES;
    CGRect keyboardBounds;
    [[note.userInfo valueForKey:UIKeyboardBoundsUserInfoKey] getValue: &keyboardBounds];
    CGFloat keyboardHeight = keyboardBounds.size.height;

            CGRect frame = self.view.frame;
            frame.size.height += keyboardHeight;
            self.view.frame = frame;

    CGPoint scrollPoint = frame.origin;
    scrollPoint.y += _tableView.contentSize.height - keyboardHeight;
    [_tableView setContentOffset:scrollPoint animated:YES];
    }
}
Vizllx
  • 9,135
  • 1
  • 41
  • 79