无法让 NSScrollView 工作
好吧,我已经用 NSScrollView 搞定了。
为什么 Y 坐标会翻转,如何更改它。 另外,我必须在通常与 NSScrollView 一起提供的自定义视图中添加数百个子视图,但滚动条不会激活:(
var Widget = new TvShowWidgetController ();
var offset = ContentView.Subviews.Count ();
Widget.View.SetFrameOrigin (new PointF (0, 150 * offset));
Widget.View.SetFrameSize (new SizeF (350, 150));
ContentView.AddSubview (Widget.View);
Ok, I've about had it with NSScrollView.
Why is the Y-coordinate flipped, and how can I change it.
Also, i must have added hundred of subviews into the Custom View that usually comes with NSScrollView, yet the scrollbars won't activate :(
var Widget = new TvShowWidgetController ();
var offset = ContentView.Subviews.Count ();
Widget.View.SetFrameOrigin (new PointF (0, 150 * offset));
Widget.View.SetFrameSize (new SizeF (350, 150));
ContentView.AddSubview (Widget.View);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Y 坐标似乎被翻转,因为 Mac OS 使用的坐标系的原点 (0,0) 是屏幕的左下角。这与 Windows 或 Linux 不同,Windows 或 Linux 的原点 (0,0) 是屏幕的左上角。
在视图中拥有翻转坐标系的唯一方法是继承 NSView 并重写 IsFipped 方法。
仅当所包含视图的大小发生变化时,滚动条才会激活。向内容视图添加子视图是不够的,因为内容视图不会自动调整大小。
The Y-coordinate seems to be flipped because Mac OS is using a coordinate system where the origin (0,0) is the left-bottom corner of the screen. This is different from Windows or Linux where the origin (0,0) is the left-top corner of the screen.
The only way to have a flipped coordinate system in a view, is to subclass NSView and to override the IsFipped method.
The scrollbars will activate only if the size of the contained view changes. Adding subviews to the content view is not enough, as there is no automatic resizing of the content view.