How show selected row when click on table view?
I have a button. When click on button then open a table view with 100 row. I user select a ny row then appear check mark. And when user click on again then i want to show t开发者_开发技巧hat selected row when view open. How do that? For example when user click on button then open table view and suppose select 50 th row. Now user click on button again then i want to show 50th row directly instead user go to scrolling table view. So tell me how do that? Thanks in advance..
Just call
- (void)selectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated scrollPosition:(UITableViewScrollPosition)scrollPosition
to your table view.
For example, following code will select 50th row in first section:
UITableView *tableView;
[tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:50 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionTop];
Use,
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:selectedRow
inSection:sectionOfSelectedRow];
[tableView scrollToRowAtIndexPath:indexPath animated:YES];
精彩评论