// wc here is an NSWindowController
[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:0.5f];
if (duplication) {
NSPoint origin = initialSize.origin;
origin.y += initialSize.size.height;
origin = [wc.window cascadeTopLeftFromPoint:origin];
origin.y -= initialSize.size.height;
//[[wc.window animator] setFrameOrigin:origin]; // Why setFrameOrigin and cascadeTopLeftFromPoint are not animated?
initialSize.origin = origin;
[[wc.window animator] setFrame:initialSize display:YES];
}
// This block should be invoked when all of the animations started above have completed or been cancelled.
// For not to show the edit window till the duplication animation not finished
[NSAnimationContext currentContext].completionHandler = ^{
if (edit)
[wc editDocument:self];
else
if (fullScreen)
[wc.window toggleFullScreen:self];
};
[NSAnimationContext endGrouping];
在这种情况下,完成块执行但不幸的是不等待窗口重新定位完成,而是立即打开窗口的编辑表并将它们一起移动。
最奇怪的是,在同一个源文件上面的几行相同类型的完成块工作正常:-O
我在这里想念什么?