Anyone know how to scroll an UITableView on iOS7?
I used to use this code and it worked very well but now seems that something is changed with contentSize (I had a problem like this with a textView)
[self.tableView scrollRectToVisible:CGRectMake(0, 0, self.tableView.contentSize.width, self.tableView.contentSize.height) animated:YES]
EDIT:
My code is like this
viewDidLoad:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
keyboardWillShow:
[self.tableView scrollRectToVisible:CGRectMake(0.0, self.tableView.contentSize.height - 1.0, 1.0, 1.0) animated:NO];
Error:
I didn't notice the scroll when the keyboard appeared because I didn't update the contentSize.
Solution (based on Daniel answer)
CGSize size = self.tableView.contentSize;
size.height += keyboardBounds.size.height;
self.tableView.contentSize = size;
[self.tableView scrollRectToVisible:CGRectMake(0.0, self.tableView.contentSize.height - 1.0, 1.0, 1.0) animated:NO];