Going to put this in the answer box for future users to see..
What you're experiencing makes it look like your notification isn't being called on the main thread, and updating the UI on a background thread is undefined behavior. The cure for this is simple, just wrap the contents of your method in a dispatch_async() call and send everything back to the main queue.
- (void)showButton:(NSNotification *)notification {
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"---CAMERA READY");
[button setHidden:NO];
[button setAlpha:0.0];
[button setTransform:CGAffineTransformScale(CGAffineTransformIdentity, 1.5, 1.5)];
[UIView animateWithDuration:.2 delay:0.0 options:UIViewAnimationOptionCurveEaseOut animations:^{
[button setAlpha:1.0];
[button setTransform:CGAffineTransformScale(CGAffineTransformIdentity, 1.0, 1.0)];
} completion:nil];
NSLog(@"---CAMERA READY");
});
}
As an alternative, you can just use a different NSNotificationCenter instance method. Specifically, -addObserverForName:object:queue:usingBlock:
allows you to specify which operation queue the callback block should be executed on. In this case, you'd want to pass [NSOperationQueue mainQueue];
.
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
self.localeChangeObserver = [center addObserverForName:NSCurrentLocaleDidChangeNotification object:nil
queue:mainQueue usingBlock:^(NSNotification *note) {
NSLog(@"The user's locale changed to: %@", [[NSLocale currentLocale] localeIdentifier]);
}];