简体   繁体   中英

TableView cell not scrolled on top after 3rd section in iOS7

I want scroll table view cell on top after clicked on cell, It is working up to 1 and 2 section but after that cell hidden behind "Keyboard".

- (void)scrollCellOnTop:(NSIndexPath *)indexPath
{

if(IS_IOS7)
{

self.supplierDetailTable .contentInset = UIEdgeInsetsMake(SCREEN_X,SCREEN_Y,  self.supplierDetailTable.bounds.size.height-50, 0);

}
else
{

self.supplierDetailTable .contentInset = UIEdgeInsetsMake(SCREEN_X, SCREEN_Y,  self.supplierDetailTable.bounds.size.height*tableInsetFraction, 0);

}

[ self.supplierDetailTable scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];

}  

Please give me a solution if you have.

In order to scroll to a row in table view, you should do like below instead:

NSIndexPath *showOnTop = [NSIndexPath indexPathForRow:row_index inSection:section_index];
[table scrollToRowAtIndexPath:showOnTop atScrollPosition:UITableViewScrollPositionTop animated:YES];

Try replace line:

[ self.supplierDetailTable scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];

with:

 NSIndexPath *iP = [NSIndexPath indexPathForRow:0 inSection:indexPath.section];
[self.supplierDetailTable scrollToRowAtIndexPath:iP atScrollPosition:UITableViewScrollPositionTop animated:YES];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM