开发者

NSTableView - Pre-Hilight a certain row

Hey all, I have a table where the user can select a preferred sound, but one should be already preselected.

I know the row number that should be p开发者_如何转开发reselected, however, I do not know the index number. How would I get that?

Cheers all, Merry Xmas.


The NSIndexPath class provides a handy method to provide the index for a given row and section: +indexPathForRow:inSection:

You could use it as follows:

- (void)selectRow:(NSUInteger)rowNum inTableView:(UITableView *)tableView
{
    NSIndexPath * indexPath = [NSIndexPath indexPathForRow:rowNum
                                                 inSection:0];
    [tableView selectRowAtIndexPath:indexPath
                           animated:YES
                     scrollPosition:UITableViewScrollPositionMiddle];
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜