如何在放大的NSScrollView中修复NSTextView的怪异大小 [英] How to fix NSTextView's weird sizing inside a magnified NSScrollView

查看:90
本文介绍了如何在放大的NSScrollView中修复NSTextView的怪异大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在NSScrollView/NSClipView里面有一个NSTextView,这是通常的设置.当我使用 [NSScrollView setMagnification:...] 放大滚动视图并调整窗口大小时,无论我拉伸还是收缩窗口,文本视图框架的宽度都会不断变大.

I have an NSTextView inside NSScrollView/NSClipView, the usual setup. When I magnify the scroll view with [NSScrollView setMagnification:...] and resize the window, the width of text view's frame gets constantly larger, regardless of whether I stretch or shrink the window.

如果未放大滚动视图,则文本视图将正常运行.我曾尝试删除约束并禁用子视图自动调整大小,但没有任何帮助.每当我设置任何放大倍率时,每次调用调整大小时,文本视图的大小都会改变.如果放大倍数小于1,则会缩小.

If the scroll view is not magnified, text view behaves normally. I have tried removing constraints and disabled subview autoresizing, but nothing helps. Whenever i set any sort of magnification, text view size changes on every call to resize. If the magnification is under 1, it shrinks.

TextContainer中的任何错误也不应该使其范围更广,因为我已经设置了 textContainer.widthTracksTextView = false;

Any bugs in TextContainer shouldn't make it wider either, as I've set textContainer.widthTracksTextView = false;

我试图通过将inset设置为int来将textContainer居中放置在NSTextView中,但是随着大小的变化,它是不可能的.我已经检查了我的代码,没有什么可以调整它的大小.这是Bug还是 setMagnify:引起了LayoutManager中约束或其他数学运算的问题?

I am trying to keep the textContainer centered in my NSTextView by setting insets to it, but it gets impossible with the varying sizes. I've gone through my code and nothing should make it resize. Is this a bug or does the setMagnify: cause problems with constraints or some other math in LayoutManager?

推荐答案

对于任何试图弄清楚这一点的人:这是由放大视图或其任何子视图的最小宽度限制引起的.好像是个错误,因为我无法将注意力集中在预期的行为上.

For anyone trying to figure this out: This is caused by a minimum width constraint for the magnified view, or any of its subviews. Seems like a bug, as I can't wrap my head around how this would be intended behaviour.

只需删除> = 约束,并在需要时做一些事情来限制运行时的大小.

Just remove the >= constraint and do something to limit the size in run-time if needed.

这篇关于如何在放大的NSScrollView中修复NSTextView的怪异大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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