<i id='sBouK'><tr id='sBouK'><dt id='sBouK'><q id='sBouK'><span id='sBouK'><b id='sBouK'><form id='sBouK'><ins id='sBouK'></ins><ul id='sBouK'></ul><sub id='sBouK'></sub></form><legend id='sBouK'></legend><bdo id='sBouK'><pre id='sBouK'><center id='sBouK'></center></pre></bdo></b><th id='sBouK'></th></span></q></dt></tr></i><div id='sBouK'><tfoot id='sBouK'></tfoot><dl id='sBouK'><fieldset id='sBouK'></fieldset></dl></div>

  1. <tfoot id='sBouK'></tfoot>

      <legend id='sBouK'><style id='sBouK'><dir id='sBouK'><q id='sBouK'></q></dir></style></legend>
        <bdo id='sBouK'></bdo><ul id='sBouK'></ul>
    1. <small id='sBouK'></small><noframes id='sBouK'>

    2. 如何很好地退出 iPhone 应用程序?

      How to quit an iPhone app nicely?(如何很好地退出 iPhone 应用程序?)

          <tbody id='VDqv9'></tbody>

        <i id='VDqv9'><tr id='VDqv9'><dt id='VDqv9'><q id='VDqv9'><span id='VDqv9'><b id='VDqv9'><form id='VDqv9'><ins id='VDqv9'></ins><ul id='VDqv9'></ul><sub id='VDqv9'></sub></form><legend id='VDqv9'></legend><bdo id='VDqv9'><pre id='VDqv9'><center id='VDqv9'></center></pre></bdo></b><th id='VDqv9'></th></span></q></dt></tr></i><div id='VDqv9'><tfoot id='VDqv9'></tfoot><dl id='VDqv9'><fieldset id='VDqv9'></fieldset></dl></div>

        • <bdo id='VDqv9'></bdo><ul id='VDqv9'></ul>
        • <tfoot id='VDqv9'></tfoot>
          <legend id='VDqv9'><style id='VDqv9'><dir id='VDqv9'><q id='VDqv9'></q></dir></style></legend>

              <small id='VDqv9'></small><noframes id='VDqv9'>

              • 本文介绍了如何很好地退出 iPhone 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                或如何模拟主页按钮按下事件?"

                or "How to simulate a home button pressed event?"

                我需要重新启动我的 iPhone 应用程序,并且我希望程序退出,因此用户只需启动它.

                I need to restart my iPhone app, and I want the program to quit, so the user will only have to start it.

                如果我只是使用 exit(0),一些更改将不会被保存,就像用户通过按主页按钮退出时一样.

                If I simply use exit(0) some changes won't get saved, as they would if the user quits by pressing the home button.

                语言更改需要重新启动.

                The restart needed for language change.

                相关代码:

                - (void)onChangeLanguage: (id)sender {
                    NSArray *lang = [NSArray arrayWithObjects:((Whatever *)sender).newLanguage, nil];
                    [[NSUserDefaults standardUserDefaults] setObject:lang forKey:@"AppleLanguages"];
                    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
                    NSArray *languages = [defaults objectForKey:@"AppleLanguages"];
                    NSString *currentLanguage = [languages objectAtIndex:0];
                
                    NSLog(@"Current language: %@", currentLanguage);
                    // ***
                }   
                

                如果用户使用主页按钮重新启动,语言将会改变.

                If the user restarts using the home button, language will change.

                如果 //***exit(0) 替换,语言不会改变.

                If // *** is replaced by exit(0), the language won't change.

                推荐答案

                我觉得调用exit就完全没问题了,之前调用[[NSUserDefaults standardUserDefaults] synchronize]你做吧.您可以在 synchronize 方法.html#//apple_ref/occ/instm/NSUserDefaults/synchronize" rel="nofollow noreferrer">苹果文档:

                I think it’s perfectly fine to call exit, just call [[NSUserDefaults standardUserDefaults] synchronize] before you do that. You can read about the synchronize method in the Apple Documentation:

                因为这个方法是自动定期调用,使用仅当您迫不及待时才使用此方法对于自动同步(对于例如,如果您的应用程序是关于退出)或者如果您想更新用户甚至默认为磁盘上的内容尽管您没有进行任何更改.

                Because this method is automatically invoked at periodic intervals, use this method only if you cannot wait for the automatic synchronization (for example, if your application is about to exit) or if you want to update the user defaults to what is on disk even though you have not made any changes.

                这篇关于如何很好地退出 iPhone 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                What is NSLayoutConstraint quot;UIView-Encapsulated-Layout-Heightquot; and how should I go about forcing it to recalculate cleanly?(什么是 NSLayoutConstraint“UIView-Encapsulated-Layout-Height?我应该如何强制它干净地重新计算?) - IT屋-程序员
                quot;Auto Layout still required after executing -layoutSubviewsquot; with UITableViewCell subclass(“执行 -layoutSubviews 后仍需要自动布局带有 UITableViewCell 子类)
                What is quot;Constrain to marginquot; in Storyboard in Xcode 6(什么是“限制边距?在 Xcode 6 的情节提要中)
                iPhone to RS-232 via Bluetooth(iPhone 通过蓝牙转 RS-232)
                How to change the preferred language of an iPhone app in iOS 4(如何在 iOS 4 中更改 iPhone 应用程序的首选语言)
                iPhone app localization by releasing separate apps for different markets(通过为不同市场发布单独的应用程序来本地化 iPhone 应用程序)
                  <bdo id='mivTY'></bdo><ul id='mivTY'></ul>

                  <legend id='mivTY'><style id='mivTY'><dir id='mivTY'><q id='mivTY'></q></dir></style></legend>

                        <tbody id='mivTY'></tbody>
                    1. <tfoot id='mivTY'></tfoot>

                          <small id='mivTY'></small><noframes id='mivTY'>

                          <i id='mivTY'><tr id='mivTY'><dt id='mivTY'><q id='mivTY'><span id='mivTY'><b id='mivTY'><form id='mivTY'><ins id='mivTY'></ins><ul id='mivTY'></ul><sub id='mivTY'></sub></form><legend id='mivTY'></legend><bdo id='mivTY'><pre id='mivTY'><center id='mivTY'></center></pre></bdo></b><th id='mivTY'></th></span></q></dt></tr></i><div id='mivTY'><tfoot id='mivTY'></tfoot><dl id='mivTY'><fieldset id='mivTY'></fieldset></dl></div>