我有NSTableView
动态排高度。我需要滚动到最后。我尝试了scrollToEndOfDocument:
,但它给出的结果与scrollRowToVisible:
相同,后者是最后一行的开头
- (void)viewDidLoad {
[super viewDidLoad];
//[[self tableView] scrollRowToVisible:[[self tableView] numberOfRows] - 1];
[[self tableView] scrollToEndOfDocument:self];
}
你的scrollRowToVisible
方法应该有效。这是一个快速的sample project,它使用一个滚动到最后一行的按钮来实现可变高度。滚动后,最后一行完全可见。
更新:对于大于周围NSClipView的表格单元格,上述技术将仅滚动到单元格的顶部。要滚动到最后一个单元格的底部,您可以使用:
let point = NSPoint(x: 0, y: tableView.frame.height)
tableView.scroll(point)
或者因为OP在ObjC:
[[self tableView] scrollPoint: NSMakePoint(0, [self tableView].frame.size.height)]