Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 移动NSView时如何接收通知_Macos_User Interface_Nsview - Fatal编程技术网

Macos 移动NSView时如何接收通知

Macos 移动NSView时如何接收通知,macos,user-interface,nsview,Macos,User Interface,Nsview,如何在移动NSView时接收通知/回调-或者在移动NSViewController时接收通知/回调 我看到有用于NSWindow(NSWindowDidMoveNotification)的方法,但我不知道如何使用NSView或NSViewController处理它 我知道NSView有一个NSWindow,这是一个有“坐标”的窗口,但我不确定如何将此NSWindow子类化以覆盖move方法 我发现了。添加这样一个观察者: [[NSNotificationCenter defaultCenter]

如何在移动NSView时接收通知/回调-或者在移动NSViewController时接收通知/回调

我看到有用于NSWindow(NSWindowDidMoveNotification)的方法,但我不知道如何使用NSView或NSViewController处理它


我知道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];

   ...
}