cocoa — What is the proper way to tell an NSWindow to redisplay its contents?

梦想的初衷 提交于 2019-12-12 13:34:23

问题


According to the NSWindow Class Reference, you should "rarely need to invoke" the NSWindow methods "display" or "setViewsNeedDisplay". So what is the usual way to redisplay the window's contents?

EDIT: I am having trouble dealing with resizing events. I just want to have everything scale proportionally. See this question. As no one seems to have any ideas for using masks to get it to happen, I want to redraw the whole thing.


回答1:


Jason's comment really should be an answer:

Generally you don't need to. Instead, you invalidate whatever view needs to be invalidated for whatever reason within the window.

In addition to that comment, I'd add that you might want to explain why you feel you need to do this. While there are sometimes perfectly valid reasons to force the whole window to redraw, they are rare and you should suspect You're Doing It Wrong™.

Use this method to flag subviews for redisplay:

- setNeedsDisplay:YES


来源:https://stackoverflow.com/questions/4676412/cocoa-what-is-the-proper-way-to-tell-an-nswindow-to-redisplay-its-contents

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!