在NSScrollView中,垂直滑块总是指向视图的底部 [英] In NSScrollView the vertical slider always points to bottom of the view

查看:318
本文介绍了在NSScrollView中,垂直滑块总是指向视图的底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Mac应用程式。在这个应用程序,我使用NSScrollView的实例作为scrollView。
我在这个ScrollView中设置了一个customView,它是NSView的一个实例:

  [scrollView setDocumentView:customView ];但是,NSScrollView的垂直Slider总是指向视图的底部:
img src =https://i.stack.imgur.com/n4Ahh.pngalt =enter image description here>



我想让滑块永远指向自定义视图的顶部:





如何进行此更改?
Plz帮助。

解决方案

我已经通过设置ScrollView的ContentView的scrollToPoint属性来解决我的问题。
下面是代码:

  [[scrollView verticalScroller] setFloatValue:0.0]; 
[[scrollView contentView] scrollToPoint:NSMakePoint(0.0,y)];
//这里y =(区别b / w scrollView的内容大小高度和scrollView的高度)


I am developing Mac app. In this app, I am using a NSScrollView's instance as scrollView. And I have set a customView which is an instance of NSView in this ScrollView as:

[scrollView setDocumentView:customView];

But, the NSScrollView's vertical Slider always points to the bottom of the view as:

I want that the slider always points to the top of the custom View as:

How can I make this change? Plz help.

解决方案

I have solved my problem by setting the scrollToPoint property of ScrollView's ContentView. Here is the code:

[[scrollView verticalScroller] setFloatValue:0.0];
[[scrollView contentView] scrollToPoint:NSMakePoint(0.0, y)];
// here y = (difference b/w scrollView's content size height and scrollView's height)

这篇关于在NSScrollView中,垂直滑块总是指向视图的底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆