Why NSWindow animator setFrame:display:animate: didn't work sometimes?

你说的曾经没有我的故事 提交于 2019-12-13 15:24:22

问题


I'm new to Cocoa.
And I'm working on extending a project's function.

The original function of that project is open a file and display the file icon in a nsbox(which is in nswindow?)

And when I click the menu to open, it works fine.
But when I open the file programmatically(using the same openfile function which the menu called), it don't show the file icon.

[[self.window animator] setFrame:frame display:YES animate:YES];

the frame is correct, but it doesn't changed.

Is there anything I missed?

You can comment so I can provide more detail.

Thank you all.


回答1:


setFrame:display:animate is a selector on the window object not the animator.

[self.window setFrame:frame display:YES animate:YES];



回答2:


Oh, I know what's going on now. I'm so stupid.

When I click the button, it's on main thread.

But when I call it on web request, it's not on main thread.

So, please make sure you do anything related to animation on main thread!



来源:https://stackoverflow.com/questions/16166338/why-nswindow-animator-setframedisplayanimate-didnt-work-sometimes

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