contentsize and contentOffset equivalent in NSScroll view

前端 未结 3 901
北海茫月
北海茫月 2020-12-13 09:52

I am porting an app from Ipad to mac. (I know that it sounds weird)

I stuck with NSScrollview. Please guide me contentsize , contentOffset equivalent in NSScrollvi

3条回答
  •  暖寄归人
    2020-12-13 10:22

    In addition to the lines from @aepryus, here are a couple more useful lines for getting/setting the scroll offset on macOS:

    //Get the current scroll offset:
    _contentViewOffset = scrollView.contentView.bounds.origin;
    
    //Set the scroll offset from the retrieved point:
    NSPoint scrollPoint = [scrollView.contentView convertPoint:_contentViewOffset toView:scrollView.documentView];
    [scrollView.documentView scrollPoint:scrollPoint];
    

提交回复
热议问题