0
Q
應用程序運行
A
回答
2
蘋果已經寫了一個演示應用程序做什麼是問:Breadcrumb
0
- (CLLocationManager *)locationManager
{
if (locationManager != nil)
return locationManager;
locationManager = [[CLLocationManager alloc] init];
//locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
locationManager.delegate = self;
return locationManager;
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
UIApplication* app = [UIApplication sharedApplication];
// Request permission to run in the background. Provide an
// expiration handler in case the task runs long.
NSAssert(bgTask == UIBackgroundTaskInvalid, nil);
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
// Synchronize the cleanup call on the main thread in case
// the task actually finishes at around the same time.
dispatch_async(dispatch_get_main_queue(), ^{
if (bgTask != UIBackgroundTaskInvalid)
{
[app endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
});
}];
// Start the long-running task and return immediately.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// Do the work associated with the task.
// Synchronize the cleanup call on the main thread in case
// the expiration handler is fired at the same time.
dispatch_async(dispatch_get_main_queue(), ^{
if (bgTask != UIBackgroundTaskInvalid)
{
[app endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}
});
});
}
- (void) locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation`
{
NSLog(@"location changed");
UIApplication* app = [UIApplication sharedApplication];
NSArray* oldNotifications = [app scheduledLocalNotifications];
// Clear out the old notification before scheduling a new one.
if ([oldNotifications count] > 0)
[app cancelAllLocalNotifications];
// Create a new notification.
UILocalNotification* alarm = [[[UILocalNotification alloc] init] autorelease];
if (alarm)
{
alarm.timeZone = [NSTimeZone defaultTimeZone];
alarm.repeatInterval = 0;
alarm.soundName = @"b.wav";
alarm.alertBody = @"Location changed!";
[app scheduleLocalNotification:alarm];
}
}
相關問題
- 1. 運行的應用程序
- 2. 運行Android應用程序
- 3. 運行Swing應用程序
- 4. 運行Flex應用程序
- 5. 運行rcp應用程序
- 6. 運行Java應用程序
- 7. 運行PowerBuilder應用程序
- 8. 運行Java應用程序
- 9. 運行Android應用程序
- 10. 運行的應用程序
- 11. 運行Yaws應用程序
- 12. 運行Groovy應用程序
- 13. 運行WinCE應用程序
- 14. 運行Hadoop應用程序
- 15. 應用程序未運行
- 16. 運行Winform應用程序
- 17. 運行Android應用程序
- 18. 運行EJB應用程序
- 19. C程序運行Mac應用程序
- 20. 運行程序時的Android應用程序運行時錯誤
- 21. 運行閃亮的應用程序內運行閃亮的應用程序
- 22. 應用程序強行關閉運行。
- 23. 並行運行多個應用程序?
- 24. 應用程序線程繼續運行
- 25. .NET MVC4 - 在父應用程序中運行應用程序
- 26. 帶手錶的應用程序運行應用程序
- 27. JVM在iOS應用程序中運行Android應用程序?
- 28. 如何從SWT應用程序運行SWT應用程序?
- 29. 從iPhone上運行應用程序隱藏應用程序
- 30. 以Android應用程序運行流星應用程序