久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      <bdo id='1m4QY'></bdo><ul id='1m4QY'></ul>
  1. <tfoot id='1m4QY'></tfoot>
    <i id='1m4QY'><tr id='1m4QY'><dt id='1m4QY'><q id='1m4QY'><span id='1m4QY'><b id='1m4QY'><form id='1m4QY'><ins id='1m4QY'></ins><ul id='1m4QY'></ul><sub id='1m4QY'></sub></form><legend id='1m4QY'></legend><bdo id='1m4QY'><pre id='1m4QY'><center id='1m4QY'></center></pre></bdo></b><th id='1m4QY'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='1m4QY'><tfoot id='1m4QY'></tfoot><dl id='1m4QY'><fieldset id='1m4QY'></fieldset></dl></div>

    1. <small id='1m4QY'></small><noframes id='1m4QY'>

      <legend id='1m4QY'><style id='1m4QY'><dir id='1m4QY'><q id='1m4QY'></q></dir></style></legend>
    2. 在 iOS 模擬器中按下主頁(yè)按鈕時(shí)不會(huì)調(diào)用 applica

      applicationDidEnterBackground and applicationWillEnterForeground method are not called when pressed home button in iOS simulator(在 iOS 模擬器中按下主頁(yè)按鈕時(shí)不會(huì)調(diào)用 applicationDidEnterBackground 和 applicationWillEnterFore
    3. <i id='yEoN7'><tr id='yEoN7'><dt id='yEoN7'><q id='yEoN7'><span id='yEoN7'><b id='yEoN7'><form id='yEoN7'><ins id='yEoN7'></ins><ul id='yEoN7'></ul><sub id='yEoN7'></sub></form><legend id='yEoN7'></legend><bdo id='yEoN7'><pre id='yEoN7'><center id='yEoN7'></center></pre></bdo></b><th id='yEoN7'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='yEoN7'><tfoot id='yEoN7'></tfoot><dl id='yEoN7'><fieldset id='yEoN7'></fieldset></dl></div>
        • <bdo id='yEoN7'></bdo><ul id='yEoN7'></ul>

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

              • <legend id='yEoN7'><style id='yEoN7'><dir id='yEoN7'><q id='yEoN7'></q></dir></style></legend>

                <tfoot id='yEoN7'></tfoot>
                  <tbody id='yEoN7'></tbody>
              • 本文介紹了在 iOS 模擬器中按下主頁(yè)按鈕時(shí)不會(huì)調(diào)用 applicationDidEnterBackground 和 applicationWillEnterForeground 方法的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                問(wèn)題描述

                我需要在后臺(tái)和前臺(tái)完成一項(xiàng)長(zhǎng)時(shí)間運(yùn)行的任務(wù).這會(huì)更新核心數(shù)據(jù).因此,為了保持 UI 響應(yīng),我創(chuàng)建了另一個(gè)線程,在其中使用不同的 managedObjectContext(MOC).因此,在后臺(tái)和前臺(tái)都設(shè)置了一個(gè)計(jì)時(shí)器,并在狀態(tài)更改時(shí)適當(dāng)?shù)赝S?在任務(wù)開(kāi)始之前和任務(wù)完成之后,當(dāng)我按下主頁(yè)按鈕時(shí),它會(huì)正確調(diào)用兩個(gè)委托方法,但是當(dāng)我按下主頁(yè)按鈕屏幕更改和 UI 掛起(變?yōu)榭瞻?時(shí),任務(wù)處于活動(dòng)狀態(tài),但兩個(gè)委托方法不是正確調(diào)用并且應(yīng)用程序不會(huì)終止.我找不到發(fā)生這種情況的原因.如果有人可以提供幫助會(huì)很有幫助.

                I need a long running task to be done in background as well as in foreground. This updates the core data. So to maintain UI responsive I created an another thread where I use different managedObjectContext(MOC). So a timer is set in background as well as in foreground and is inactivated appropriately when state changes. Before the task is starting and after the task is completed when I press home button it calls the two delegate methods properly but during the task is active when I press home button screen changes and UI hangs (becomes blank) but the two delegate methods are not called properly and the app is not terminated. I could not find the reason why this happens so. It would be helpful if someone can help.

                我將附上所需的代碼:

                -(void) startTimerThread
                {
                    dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
                        // Add code here to do background processing
                        NSManagedObjectContext *context = [[NSManagedObjectContext alloc] init];
                        [context setPersistentStoreCoordinator:[(AppDelegate *)[[UIApplication sharedApplication] delegate] persistentStoreCoordinator]];
                        self.managedObjectContext = context;
                        [[NSNotificationCenter defaultCenter] addObserver:self
                                                                 selector:@selector(mergeChanges:)
                                                                     name:NSManagedObjectContextDidSaveNotification
                                                                   object:context];
                        NSLog(@"managedObjContext : %@
                ",self.managedObjectContext);
                        [self getDataFromFile];
                
                        dispatch_async( dispatch_get_main_queue(), ^{
                            // Add code here to update the UI/send notifications based on the
                            // results of the background processing
                
                            [[NSNotificationCenter defaultCenter] postNotificationName:@"ReloadAppDelegateTable" object:nil];
                            [context release];
                            [[NSNotificationCenter defaultCenter] removeObserver:self 
                                                                            name:NSManagedObjectContextDidSaveNotification
                                                                          object:context];
                        });
                    });
                }
                
                - (void)applicationDidEnterBackground:(UIApplication *)application
                {
                    NSLog(@"Background
                ");
                    [self.notificationTimer invalidate];
                    self.notificationTimer = nil;
                    UIApplication  *app = [UIApplication sharedApplication];
                    self.bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
                        [app endBackgroundTask:bgTask]; 
                        bgTask = UIBackgroundTaskInvalid;
                    }];
                
                    //start location update timer and background timer 
                    self.timer = [NSTimer scheduledTimerWithTimeInterval:180 target:self
                                                                selector:@selector(startLocationServices) userInfo:nil repeats:YES];
                    self.locationManager.delegate = self; 
                    [self.locationManager startUpdatingLocation]; 
                
                    self.logDownloader.managedObjectContext = self.managedObjectContext;
                    NSLog(@"managedObjContext : %@
                ",self.logDownloader.managedObjectContext);
                    self.backgroundTimer = [NSTimer scheduledTimerWithTimeInterval:90 target:self.logDownloader selector:@selector(getDataFromFile) userInfo:nil repeats:YES];
                }
                
                - (void)applicationWillEnterForeground:(UIApplication *)application
                {
                    NSLog(@"Foreground
                ");
                    //invalidate background timer and location update timer
                    [self.timer invalidate];
                    [self.backgroundTimer invalidate];
                    self.timer = nil;
                    self.notificationTimer = nil;
                
                    self.logDownloader.managedObjectContext = self.managedObjectContext;
                    NSLog(@"managedObjContext : %@
                ",self.logDownloader.managedObjectContext);
                    [[NSNotificationCenter defaultCenter] postNotificationName:@"ReloadAppDelegateTable" object:nil];
                
                    self.notificationTimer = [NSTimer scheduledTimerWithTimeInterval:180 target:self.logDownloader selector:@selector(startTimerThread) userInfo:nil repeats:YES];
                }
                

                推薦答案

                原因applicationDidEnterBackground:applicationDidEnterForeground: 永遠(yuǎn)不會(huì)被調(diào)用,因?yàn)檫@些方法與 應(yīng)用程序不在后臺(tái)運(yùn)行這個(gè)選項(xiàng)可以在你的***-info.plist中找到.如果此選項(xiàng)設(shè)置為 YES ,那么您的應(yīng)用程序?qū)⒂肋h(yuǎn)不會(huì)調(diào)用這些方法,因?yàn)楫?dāng)您使用已將選項(xiàng)設(shè)置為 YES 實(shí)例的應(yīng)用程序按下主頁(yè)按鈕時(shí),這些方法正在運(yùn)行的應(yīng)用程序?qū)⒈唤K止,因此每次按下主頁(yè)按鈕然后選擇應(yīng)用程序圖標(biāo)時(shí),都會(huì)創(chuàng)建一個(gè)新實(shí)例,因此它正在使用 applicationWillTerminate:.

                The reason why applicationDidEnterBackground: and applicationDidEnterForeground: are never called is because these methods are used in joint with Application does not run in background this option can be found in your ***-info.plist. If this option is set to YES than your app will never call these methods, because these when you press the home button with an app that has set the option to YES the instance of the app that is running will get terminated so everytime you press the home button and then select the app icon a new instance is being created so it is using applicationWillTerminate:.

                Kirti mali 所說(shuō)的方法也將是不正確的方法來(lái)使用你想要的,原因是 applicationDidBecomeActive:applicationWillResignActive: 用于接聽(tīng)電話等情況.正在運(yùn)行的實(shí)例不會(huì)被終止,也不會(huì)被發(fā)送到后臺(tái).該實(shí)例會(huì)暫停,直到用戶完成該調(diào)用,然后它將再次變?yōu)榛顒?dòng)狀態(tài).

                The methods that Kirti mali has said would also be the incorrect methods to use for want you are after, the reason being is that applicationDidBecomeActive: and applicationWillResignActive: are used when something like when you answer a phone call. The instance running is not terminated neither is it sent to the background. The instance is paused until the user has finished on that call when it will become active again.

                因此,如果您希望應(yīng)用程序在后臺(tái)運(yùn)行,解決方案是更改選項(xiàng)應(yīng)用程序不在后臺(tái)運(yùn)行".在 ***-info.plist 中為 NO 只是 applicationDidBecomeActive:applicationWillResignActive: 是這些方法的錯(cuò)誤使用方式.

                So the solution to this would be if you want the app to run in background would be to change the option "Application does not run in background" in the ***-info.plist to be NO just applicationDidBecomeActive: and applicationWillResignActive: is the wrong way for these methods to be used.

                請(qǐng)參閱 上的蘋(píng)果文檔UIApplicationDelegate 以更好地理解這些方法.

                Please see the apple documentation on UIApplicationDelegate to get a better understanding of these methods.

                這篇關(guān)于在 iOS 模擬器中按下主頁(yè)按鈕時(shí)不會(huì)調(diào)用 applicationDidEnterBackground 和 applicationWillEnterForeground 方法的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                相關(guān)文檔推薦

                Help calculating X and Y from Latitude and Longitude in iPhone(幫助從 iPhone 中的緯度和經(jīng)度計(jì)算 X 和 Y)
                CLLocation returning negative speed(CLLocation 返回負(fù)速度)
                Calculate bearing between two locations (lat, long)(計(jì)算兩個(gè)位置之間的方位角(緯度、經(jīng)度))
                watchPosition() vs getCurrentPosition() with setTimeout(watchPosition() 與 getCurrentPosition() 與 setTimeout)
                iOS 6 breaks GeoLocation in webapps (apple-mobile-web-app-capable)(iOS 6 破壞了 webapps 中的 GeoLocation (apple-mobile-web-app-capable))
                Determine iPhone user#39;s country(確定 iPhone 用戶所在的國(guó)家)

                • <legend id='x05Wd'><style id='x05Wd'><dir id='x05Wd'><q id='x05Wd'></q></dir></style></legend>
                • <tfoot id='x05Wd'></tfoot>

                    <tbody id='x05Wd'></tbody>
                  • <bdo id='x05Wd'></bdo><ul id='x05Wd'></ul>
                  • <i id='x05Wd'><tr id='x05Wd'><dt id='x05Wd'><q id='x05Wd'><span id='x05Wd'><b id='x05Wd'><form id='x05Wd'><ins id='x05Wd'></ins><ul id='x05Wd'></ul><sub id='x05Wd'></sub></form><legend id='x05Wd'></legend><bdo id='x05Wd'><pre id='x05Wd'><center id='x05Wd'></center></pre></bdo></b><th id='x05Wd'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='x05Wd'><tfoot id='x05Wd'></tfoot><dl id='x05Wd'><fieldset id='x05Wd'></fieldset></dl></div>

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

                          主站蜘蛛池模板: 91精品国产91久久久久久吃药 | 一级黄a| 欧洲尺码日本国产精品 | 国产精品视频导航 | 99久久久国产精品免费消防器 | 国产在线播放一区二区三区 | 欧美福利影院 | 久久综合av| www.欧美.com| 国产a一区二区 | 午夜丁香视频在线观看 | 日本高清中文字幕 | 久久在视频 | 久久精品亚洲国产 | 欧美精品一区二区在线观看 | 四虎最新视频 | 欧美老妇交乱视频 | 成人欧美一区二区三区黑人孕妇 | 福利一区二区 | 久久免费精品视频 | 欧美性受xxxx | 久久久国产精品视频 | 日韩精品一二三区 | av在线天堂网 | 亚洲激情一区二区 | 久久99深爱久久99精品 | 欧美福利 | 天堂在线91 | 日日干天天操 | 91看片| 欧美 日韩 亚洲91麻豆精品 | 国产精品综合一区二区 | 久久亚洲精品久久国产一区二区 | 亚洲一区二区久久久 | 国产精品美女久久久久aⅴ国产馆 | 日韩在线综合 | 日韩在线电影 | 欧美成人精品欧美一级 | 国产精品乱码一二三区的特点 | www天天操| 精品久久一区 |