How can I detect if a user has changed the iPhone

2019-07-27 03:04发布

I am going to use these language changes as triggers in the code that I'm going to write.

For example:

if languageHasChanged() {
    //do something
}

标签: ios swift swift3
2条回答
Emotional °昔
2楼-- · 2019-07-27 03:27

If NSLocale.currentLocaleDidChangeNotification is not available, you can store the actual Locale in applicationWillTerminate and applicationWillEnterBackground in a variable, and compare it to the locale in applicationDidBecomeActive.

查看更多
Anthone
3楼-- · 2019-07-27 03:40

Register for the NSLocale.currentLocaleDidChangeNotification notification.

NotificationCenter.default.addObserver(self, selector: #selector(localeChanged), name: NSLocale.currentLocaleDidChangeNotification, object: nil)

func localeChanged() {

}
查看更多
登录 后发表回答