【发布时间】:2011-10-10 08:47:26
【问题描述】:
由于位置区域事件,我有一个关于在后台模式下运行时显示 UIAlertView 的问题。我在此处对类似问题进行了广泛的搜索,并下载了 Apple Breadcrumb 示例,但它并未尝试显示警报。
我的应用在进入后台模式之前切换到区域监控:
[self.locMan startMonitoringForRegion:targetRegion desiredAccuracy:100];
然后我监控区域进入和退出如下:
-(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region
{
NSLog(@"Exited region");
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Region Boundary Crossed!"
message:@"Exited region"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Show",nil ];
[alertView show];
[alertView release];
}
-(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
NSLog(@"Entered region");
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Region Boundary Crossed!"
message:@"Entered region"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Show",nil ];
[alertView show];
[alertView release];
}
我已使用模拟器运行此程序,以确认它正确切换到区域监控。但是,在 iPhone 上,在后台模式下运行时我看不到警报,但在重新激活应用程序时会显示所需的警报,似乎在排队等待。
在我的 info.plist 文件中,我已将“所需的后台模式 - 项目 0”设置为“应用程序注册以进行位置更新”,将“所需的设备功能 - 项目 0”设置为“位置服务”,将“项目 1”设置为“全球定位系统'。
非常感谢任何帮助!
【问题讨论】:
标签: iphone objective-c location uialertview background-process