In a macOS project I'm trying to get and set the scroll cursor position of a NSTableView the code seems to work because don't appairs errors but the cursor don't update.
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
Am I forgetting something?
contentView.bounds.origin
will almost certainly give you a point at 0,0
pretty much always as that's not the value you are expecting. bounds
tell you an information about a position of the view which displays the canvas, not the inner offset of the scrolled document.
I guess one -documentRect
or -documentVisibleRect
properties contains the proper offset value you're looking for.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.