在MacOS项目中,我要获取并设置nstableView的滚动光标位置该代码似乎有效,因为不应用错误,但光标不会更新。<<<<<<<<<<<<<<<<
var clipOrigin = tableView.enclosingScrollView?.contentView.bounds.origin // get the position
clipOrigin = CGPoint (x: 0.0, y: 3.0) // set a new position
tableView.enclosingScrollView?.contentView.scroll(to: clipOrigin!) // set the new position
我忘记了什么吗?
contentView.bounds.origin
几乎可以肯定会给您一个0,0
的观点,因为这不是您期望的价值。bounds
告诉您有关显示画布的视图位置的信息,而不是滚动文档的内部偏移。
我猜一个-documentRect
或-documentVisibleRect
属性包含您要寻找的正确偏移值。