我在 UIViewController 中UIView有一个MKMapView, ,它仅在用户点击按钮时出现。
过程如下:
- 一个
CLLocationManager对象在header文件中被声明为私有成员。 - A
UIView出现MKMapView(最初框架在边界外。移动到用户操作的视图边界内,在同一范围内viewController)。 它被初始化:
locationManager = [[CLLocationManager alloc] init]; locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move locationManager.desiredAccuracy = kCLLocationAccuracyBest; // 100 m [locationManager startUpdatingLocation]; CLLocation *location = [locationManager location]; CLLocationCoordinate2D coordinate = [location coordinate]; MKCoordinateSpan span = MKCoordinateSpanMake(0.04, 0.04); MKCoordinateRegion region = MKCoordinateRegionMake(coordinate, span); mapView.showsUserLocation = YES; [mapView setRegion:region animated:YES];使用获取附近的位置
Foursquare API
现在,我希望在view从可见边界中删除位置锁定时停止位置锁定。我试过了stopUdatingUserLocation。我也是released的locationManager,但是GPS锁图标是持久化的statusBar。据我了解,连续 GPS 锁定会耗尽电池电量,我想停止这种情况。我该怎么办?