iPhone 中从非活动状态转为活动状态时应用程序崩溃
我正在制作一个应用程序,其中必须在设置的时间后在地图上显示用户当前位置,我已经对此进行了研究,它对我有用,但是如果我让应用程序保持打开状态,并且 5 分钟后应用程序进入非活动状态,我会停止位置更新,5 分钟后,如果我再次重新锁定滑块并检查应用程序,它会进入活动状态,已调用位置更新并显示当前位置,但是有几次它从非活动状态崩溃到活动状态
- (void)applicationWillResignActive:(UIApplication *)application {
[locationManger stopUpdatingLocation];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
locationManger.delegate = self;
[locationManger startUpdatingLocation];
}
I am making an application in which have to show user current location on map with some time set, i have worked on that and it is working for me, however if i leave the app open and after 5 minutes app goes to inactive state i stop the location update and after 5 minutes if i again relock the slider and check the app, it comes into active state , have called location update and show the current location, however few times it got crashed from inactive to active state
- (void)applicationWillResignActive:(UIApplication *)application {
[locationManger stopUpdatingLocation];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
locationManger.delegate = self;
[locationManger startUpdatingLocation];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您只需在地图上显示用户的位置,那么您不需要 CLLocationManager。只需使用
mapView.showsUserLocation = YES;
If you only have to show the user's location on the map, then you dont need CLLocationManager. Just use
mapView.showsUserLocation = YES;