I have UITableViewController want to scroll when user tap on the bottom of the textfield using scrollToRowAtIndexPath method
// ViewController
@interface PersonalInfoViewController : UITableViewController{
}
On the textFiled Delegate methods.
-(void) textFieldDidBeginEditing:(UITextField *)textField {
UITableViewCell *textFieldRowCell = (UITableViewCell *) textField.superview.superview;;
NSIndexPath* path = [self.tableView indexPathForCell:textFieldRowCell];
[self performSelector:@selector(scrollToCell:) withObject:path afterDelay:0.5f];
}
// Scroll Method
-(void) scrollToCell:(NSIndexPath*) path {
NSLog(@"%@",path);
[self.tableView scrollToRowAtIndexPath:path atScrollPosition:UITableViewScrollPositionNone animated:NO];
}
Console O/P
// Size
NSLog(@"%@",NSStringFromCGSize(self.tableView.contentSize)); {320, 711.5}
// Bounds
NSLog(@"%@",NSStringFromCGRect(self.tableView.frame)); {{0, 0}, {320, 568}}
// IndexPath
<NSIndexPath: 0x8e981f0> {length = 2, path = 3 - 0}
<NSIndexPath: 0x8eaa600> {length = 2, path = 3 - 1}
<NSIndexPath: 0x9967d20> {length = 2, path = 2 - 1}
So question is that.
- Why tableView not move to particular indexPath in scrollToRowAtIndexPath.
- Where and how to use scrollToRowAtIndexPath.
I don't think so to use scrollToRowAtIndexPath we need to set contectSize
and ContectOffset
Guys check my contect Size and Bounds o/p. How can you say that contect size is smaller than height
I found that UITableViewScrollPositionTop working for the top some of the row but not for the bottom of the last 4 to 5