Why NSWindow animator setFrame:display:animate: di

2019-07-19 05:46发布

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.

2条回答
Viruses.
2楼-- · 2019-07-19 06:02

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

[self.window setFrame:frame display:YES animate:YES];
查看更多
兄弟一词,经得起流年.
3楼-- · 2019-07-19 06:08

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!

查看更多
登录 后发表回答