Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.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 检测OSX上的监视器更改_Macos_Notifications_Screen - Fatal编程技术网

Macos 检测OSX上的监视器更改

Macos 检测OSX上的监视器更改,macos,notifications,screen,Macos,Notifications,Screen,我有一个应用程序,它会请求有关监视器更改的通知,以便重新配置,如果我添加监视器,这些通知当前不会被触发: [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(distNotificationHook:)

我有一个应用程序,它会请求有关监视器更改的通知,以便重新配置,如果我添加监视器,这些通知当前不会被触发:

    [[NSDistributedNotificationCenter defaultCenter] addObserver:self
                                                        selector:@selector(distNotificationHook:)
                                                            name:NSApplicationDidChangeScreenParametersNotification
                                                          object:nil];


    [[NSDistributedNotificationCenter defaultCenter] addObserver:self
                                                        selector:@selector(distNotificationHook:)
                                                            name:@"com.apple.BezelServices.BMDisplayHWReconfiguredEvent"
                                                          object:nil];

他们过去常工作。。但现在不是了。有人知道我做错了什么吗?

问题是这需要使用NSNotificationCenter,而不是NSDistributedNotificationCenter:

  [[NSNotificationCenter defaultCenter] addObserver:self
                                                        selector:@selector(distNotificationHook:)
                                                            name:@"com.apple.BezelServices.BMDisplayHWReconfiguredEvent"
                                                          object:nil];