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应用程序运行流星应用程序