Why NSWindow animator setFrame:display:animate: di

2019-07-19 06:04发布

问题:

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!