无法更改列宽以响应outlineViewItemDidExpand [英] Can't change column width in response to outlineViewItemDidExpand

查看:102
本文介绍了无法更改列宽以响应outlineViewItemDidExpand的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我在 NSOutlineView 中的节点扩展时,我都希望将列宽更新为最宽条目的宽度.因此,我的代表收听 outlineViewItemDidExpand 并调用

I want to update the column width to the width of the widest entry whenever a node in my NSOutlineView is expanded. Thus, my delegate listens to outlineViewItemDidExpand and calls

[column setWidth:maxColumnWidth];

在其中. maxColumnWidth 是最宽条目的宽度.

in it. maxColumnWidth is the width of the widest entry.

但是,由于某种原因,从 outlineViewItemDidExpand 内部调用 setWidth 似乎没有任何作用.当我稍后致电时,例如作为对按钮单击的响应,它可以很好地工作,但是在 outlineViewItemDidExpand 内部,它什么也没做.

However, for some reason, calling setWidth from inside outlineViewItemDidExpand doesn't seem to do anything. When I call it later, e.g. as a response to a button click, it works just fine, but from within outlineViewItemDidExpand it just does nothing.

那么,只要用户单击扩展器图标,我该怎么做才能更新列宽?非常感谢!

So any idea what I could do to update the column width whenever the user clicks on an expander icon? Thanks a lot!

推荐答案

如果 autoresizesOutlineColumn YES (默认),则大纲视图将在之后调整大纲列的大小outlineViewItemDidExpand .解决方案:将 autoresizesOutlineColumn 设置为 NO .

If autoresizesOutlineColumn is YES (default) then the outline view resizes the outline column after outlineViewItemDidExpand. Solution: set autoresizesOutlineColumn to NO.

这篇关于无法更改列宽以响应outlineViewItemDidExpand的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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