简体   繁体   English

应用程序在后台时更改设备语言

[英]Changing the device language when application is in background

I am running my iPod touch application and then go in background and change the device language from Settings application and try to bring that application on foreground.我正在运行我的 iPod touch 应用程序,然后在后台运行 go 并从设置应用程序更改设备语言并尝试将该应用程序置于前台。 My application gets restarted and I do not land on the screen where I left the application when I went into the background.我的应用程序重新启动,当我进入后台时,我没有登陆我离开应用程序的屏幕。

Is this because a KILL signal is sent by settings application when language was changed?这是因为更改语言时设置应用程序发送了 KILL 信号吗? Is it the desired behavior?这是期望的行为吗?

I wasn't aware the switching the language would cause apps to be terminated, but that's not shocking.我不知道切换语言会导致应用程序被终止,但这并不令人震惊。 It's a very straightforward way to get what the user wants.这是获得用户想要的东西的一种非常直接的方式。 Your problem isn't the language change, though.不过,您的问题不在于语言更改。 The problem is that you're not responding correctly to a notification of termination.问题是您没有正确响应终止通知。 You can be terminated at any time when you're in the background, and it's your job to deal with it.当你在后台时,你可以随时被终止,处理它是你的工作。

Your application delegate should implement applicationWillTerminate: (or you can observe UIApplicationWillTerminateNotification wherever it is convenient).您的应用程序委托应该实现applicationWillTerminate: (或者您可以在方便的地方观察UIApplicationWillTerminateNotification )。 When you receive this, you should save off sufficient information to get yourself back to where you were when you restart.收到此信息后,您应该保存足够的信息,以使自己回到重新启动时的状态。 As much as possible, you should make it look to the user that you did not terminate.您应该尽可能让用户认为您没有终止。 The easiest place to save state is usually in NSUserDefaults , but you can use any mechanism you like.保存 state 最简单的地方通常是在NSUserDefaults中,但你可以使用任何你喜欢的机制。

Handling application restart is one of those things that separates excellent iOS applications from "good enough."处理应用程序重启是将优秀的 iOS 应用程序与“足够好”区分开来的事情之一。

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

相关问题 更改设备旋转时的iphone背景图像 - iphone background images when changing device rotation 当应用程序在后台或设备被锁定时运行代码 - Running the code when application is in the background or device is locked 在设备上安装时如何将应用程序发送到后台? - How send application to background when install on device? 在现有应用程序上更改设备类型 - Changing Device type on existing application 本地化请求权限基于应用程序语言而非设备语言 - Localization request permission base on the application language not device language iPhone应用程序语言中的问题在不断变化 - Issue in iPhone application language changing on the fly 如何在设备重启时在后台运行ios应用程序? - How to run ios application in background on device restart? 更改语言时不想重新启动应用程序 - Dont want to restart the app when changing language 当我在iPhone设置中切换到另一种语言时,应用程序未更改语言 - App is not changing the language when I switch to another language in the iPhone Settings 从应用程序设置更改我的IPHONE应用程序的语言,而无需更改设备的语言 - make the language of my IPHONE app change from the app settings without changing the language of the device
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM