Programmatically scroll NSScrollView to the right

∥☆過路亽.° 提交于 2019-12-01 12:40:33

问题


Everything is in the title; I want to programmatically scroll an NSScrollView to the right so I can see the end of my document.

I tried this :

let width = scrollView.frame.size.width
let height = scrollView.frame.size.height
let toRight = CGRectMake(width, 0, width, height)
scrollView.scrollRectToVisible(toRight)

But it didn't do anything.

Any help would be appreciated !


回答1:


I finally got it to work by scrolling the content view :

scrollView.contentView.scrollPoint(NSPoint(width, 0))



回答2:


Try

let toRight = CGRect(x: width, y: 0, width: 0, height: height)
scrollView.scrollRectToVisible(toRight)


来源:https://stackoverflow.com/questions/35939381/programmatically-scroll-nsscrollview-to-the-right

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!