开发者

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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜