简体   繁体   English

无法获取NSCurrentLocaleDidChangeNotification的本地通知

[英]Unable to get a local notification for NSCurrentLocaleDidChangeNotification

I have implemented the following sample code to test if i can receive a notification for locale change(In my case, I need to get a notification when I change the language). 我已经实现了以下示例代码,以测试是否可以接收到有关区域设置更改的通知(就我而言,当我更改语言时,需要获得通知)。 But when I change the language and come back to the app, I am not getting the log statement which I have given. 但是,当我更改语言并返回到应用程序时,我没有收到给出的日志语句。 Is it the way to get the notification? 是否可以获取通知? If yes, what might be the reason for not getting the log displayed. 如果是,则可能是未显示日志的原因。

-(void)applicationDidBecomeActive:(UIApplication *)application {
 [[NSNotificationCenter defaultCenter] addObserver:self
                                  selector:@selector(notify:) 
                                  name:NSCurrentLocaleDidChangeNotification 
                                  object:nil];
}

-(void)notify:(NSNotification*)notification
{
NSLog(@"Notification observed");
}

If user change language, iOS restarts your application. 如果用户更改语言,iOS将重新启动您的应用程序。
You can get this notification if user change current calendar or other components of current locale. 如果用户更改当前日历或当前语言环境的其他组件,则可以获得此通知。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM