在iOS 7中未观察到UIAccessibilityInvertColorsStatusDidChangeNotification

Com*_*ast 4 iphone accessibility objective-c nsnotifications ios

我不确定这是iOS 7的bug还是什么.但是......我无法UIAccessibilityInvertColorsStatusDidChangeNotification上班.

所以,当我开始我的笔尖时,我这样做:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {

        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(inverted)
                                                     name:UIAccessibilityInvertColorsStatusDidChangeNotification
                                                   object:nil];
    }
    return self;
}
Run Code Online (Sandbox Code Playgroud)

稍后在我的代码中我收到了通知:

- (void)inverted {
    if(UIAccessibilityIsInvertColorsEnabled()) {
        NSLog(@"setting tintcolor to cyan");
        self.view.tintColor = [UIColor cyanColor];
        [self tintColorDidChange];
    } else {
        NSLog(@"setting tintcolor to red");
        self.view.tintColor = [UIColor redColor];
        [self tintColorDidChange];
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,当我的应用程序运行时,我通过主页按钮上的tripple-tap更改了反转颜色模式,应用程序中没有任何反应.不要在控制台上收到消息,不要改变tintColor,不要得到什么.

我在iOS 6和iOS 7上对此进行了测试.我尝试将我的构建目标设置为iOS 6.1而不是4.3,并且也没有修复它.

我尝试添加-(void)inverted;到我的界面,但没有解决它.我尝试在倒置后添加冒号,但也没有修复它,并且文档说这个通知无论如何都没有参数.

显然我做错了什么.什么?提前致谢.

Com*_*ast 5

很奇怪......一定是个bug但是......

为了解决这个问题,我所要做的就是打电话

UIAccessibilityIsInvertColorsEnabled();
Run Code Online (Sandbox Code Playgroud)

在viewController的viewDidLoad方法中.在我添加了一行代码之后,现在通知就好了(虽然仍有一帧显示错误).显然,除非你先调用它,否则根本不会观察到反转颜色通知.Apple的文档没有告诉你这一点.

绝对是我遇到过的一个奇怪的事情.