更新时间:2023-09-30 12:50:40
如果您已经在区域,因为状态未更改,您不会收到通知。
If you are already in the region, you will not get notified that you entered a region, because the state hasn't changed.
在iOS 7及更高版本上,您可以使用-[CLLocationManager requestStateForRegion:]
在开始监视区域时请求区域的当前状态。在您的CLLocationManagerDelegate上-(void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region
。
On iOS 7 and later, you can use -[CLLocationManager requestStateForRegion:]
to request the current state for a region as you start to monitor it. -(void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region
on your CLLocationManagerDelegate.
如果需要支持iOS 6,则可以通过-[CLRegion containsCoordinate:]
来检查区域是否包含设备的当前坐标,从而手动完成此操作。
If you need to support iOS 6, you can do this manually by checking if the region contains the device's current coordinate, via -[CLRegion containsCoordinate:]