我有一个应用程序会询问有关监视器更改的通知以便重新配置,如果我添加监视器,这些应用程序当前不会被触发:
[[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];
他们曾经工作..但不再。谁知道我在这里做错了什么?
答案 0 :(得分:0)
事实证明,问题是这需要使用NSNotificationCenter,而不是NSDistributedNotificationCenter:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(distNotificationHook:)
name:@"com.apple.BezelServices.BMDisplayHWReconfiguredEvent"
object:nil];