Macos 移动NSView时如何接收通知
如何在移动NSView时接收通知/回调-或者在移动NSViewController时接收通知/回调 我看到有用于NSWindow(NSWindowDidMoveNotification)的方法,但我不知道如何使用NSView或NSViewController处理它Macos 移动NSView时如何接收通知,macos,user-interface,nsview,Macos,User Interface,Nsview,如何在移动NSView时接收通知/回调-或者在移动NSViewController时接收通知/回调 我看到有用于NSWindow(NSWindowDidMoveNotification)的方法,但我不知道如何使用NSView或NSViewController处理它 我知道NSView有一个NSWindow,这是一个有“坐标”的窗口,但我不确定如何将此NSWindow子类化以覆盖move方法 我发现了。添加这样一个观察者: [[NSNotificationCenter defaultCenter]
我知道NSView有一个NSWindow,这是一个有“坐标”的窗口,但我不确定如何将此NSWindow子类化以覆盖move方法 我发现了。添加这样一个观察者:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(frameDidChange:)
name:NSViewFrameDidChangeNotification
object:self.view];
- (void)frameDidChange:(NSNotification*)notification {
NSView* view = [notification object];
...
}
和这样的选择器:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(frameDidChange:)
name:NSViewFrameDidChangeNotification
object:self.view];
- (void)frameDidChange:(NSNotification*)notification {
NSView* view = [notification object];
...
}