iOS¿ª·¢ - °Ù¶ÈµØͼºǫ́³ÖÐø¶¨Î»

來源:互聯網
上載者:User

iOS¿ª·¢ - °Ù¶ÈµØͼºǫ́³ÖÐø¶¨Î»

ÖÇ°ÓÐ×öÒ»¸ö¶¨Î»µÄÏîÄ¿£¬ÀàËÆàÖàÖ´ò³µÄÇÑù¡£ ÐèÒªºǫ́³ÖÐø¶¨Î»¡£

ÕâÀïÑ¡ÔñÁ˰ٶȵØͼ£¬²»¹ýÔÚºǫ́³ÖÐø¶¨Î»·½Ã棬 ÖÇ°Ö»ÊǼòµ¥µÄÉèÖÃÈçÏÂ:


²»¹ý¾²âÊÔ·¢ÏÖ, ÕâÑùÉèÖÃÍ꣬ÔÚºǫ́ÔËÐдó¸Å30·ÖÖÓ£¬Óֻᱻcrashµô¡£ ÖØдò¿ªÓ¦ÓÃÔò×Ô¶¯»Ö¸´¶¨Î»¡£<†·Ÿ"http://www.bkjia.com/kf/ware/vc/" target="_blank" class="keylink">vcD48cD48YnIgLz48L3A+PHA+tbHIu6Os1eKyu8rHztLDx8/r0qq1xNCnufujrMv50tTV28zawcvPwqOsyrXP1sHLuvPMqLPW0Pi2qM67oaM8L3A+PHA+19y1xMC0y7WjrL7NysfA+9PDvfjI67rzzKi6887Sw8e/ybLZv9i1xDEwt9bW06OswLTN6rPJ0rvQqcrCx+mhozwvcD48cD7OqrTvtb2z1tD4tqjOu6Osw78xMLfW1tOho9fUtq/W2NDCv6rG9Laozruho9Xi0fm+zb3ivvbOysziwcuhozwvcD48cD48YnIgLz48L3A+PHA+vt/M5cjnz8I6PC9wPjxwPjxiciAvPjwvcD48cD5BcHBEZWxlZ2F0ZS5oPGJyIC8+PC9wPjxwPjxwcmUgY2xhc3M9"brush:java;">@property (nonatomic, unsafe_unretained) UIBackgroundTaskIdentifier bgTask;
AppDelegate.m

- (void)backgroundHandler{    NSLog(@"### -->backgroundinghandler");        UIApplication* app = [UIApplication sharedApplication];        bgTask = [app beginBackgroundTaskWithExpirationHandler:^{                [app endBackgroundTask:bgTask];        bgTask = UIBackgroundTaskInvalid;            }];        // Start the long-running task    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{                // ÄúÏë×öµÄÊÂÇé,        // ±ÈÈçÎÒÕâÀïÊÇ·¢Ë͹㲥, ÖØм¤»î¶¨Î»        // È¡µÃiosϵͳΨһµÄÈ«¾ÖµÄ¹ã²¥Õ¾ ֪ͨÖÐÐÄ        NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];        //ÉèÖù㲥ÄÚÈÝ        NSDictionary *dict = [[NSDictionary alloc]init];        //½«ÄÚÈÝ·â×°µ½¹ã²¥ÖÐ ¸øiosϵͳ·¢Ë͹㲥        // LocationThemeƵµÀ        [nc postNotificationName:@"LocationTheme" object:self userInfo:dict];    });    }

- (void)applicationDidEnterBackground:(UIApplication *)application{    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.     // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.        BOOL backgroundAccepted = [[UIApplication sharedApplication] setKeepAliveTimeout:600 handler:^{ [self backgroundHandler]; }];        if (backgroundAccepted)            {        NSLog(@"backgrounding accepted");    }    [self backgroundHandler];}



È»ºóÔÚ¿ªÆô¶¨Î»µÄλÖ㬳ÉΪ¹ã²¥½ÓÊÕÕߣ¬²¢ÇÒÖØм¤»î¶¨Î»

//³õʼ»¯BMKLocationService    myLocService = [[BMKLocationService alloc]init];    myLocService.delegate = self;    //Æô¶¯LocationService    [myLocService startUserLocationService];

NSNotificationCenter *nc2 = [NSNotificationCenter defaultCenter];        // ³ÉΪÌýÖÚÒ»µÓй㲥¾ÍÀ´µ÷ÓÃself recvBcast:º¯Êý    [nc2 addObserver:self selector:@selector(activeLocation:) name:@"LocationTheme" object:nil];

- (void) activeLocation:(NSNotification *)notify{    [myLocService stopUserLocationService];    //³õʼ»¯BMKLocationService    myLocService = [[BMKLocationService alloc]init];    myLocService.delegate = self;    //Æô¶¯LocationService    [myLocService startUserLocationService];}


µ±È»£¬ÉÏÃæµÄ·½Ê½£¬¿ÉÄÜ·½·¨±È½ÏÔü£¬´úÂëҲдµÄ±È½ÏÂÒ¡£

Ö»ÊÇÌá¹Ò»ÖÖ½â¾ö°ì·¨¶øÒÑ¡£


相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.