14th Mon
UILocationManager
ユーザーが設定でロケーションの設定をいぢると、
didFailWithError
が呼ばれる。Grant したときでさえも code = 0 で呼ばれる!
ユーザーが設定でロケーションの許可を与えなかったとき、だからといってstopUptatingLocation を呼んでしまうと、その後許可を与えたことがわからなくなる。ネットの例はこれが多いので注意。
ruby>>
- (void)
locationManager:(CLLocationManager*)pLM
didFailWithError:(NSError*)pError
{ assert( [ pError.domain isEqual:kCLErrorDomain ] );
switch ( pError.code )
{
case 0: // User grant permission to access Location.
break;
case 1: // User change permittion to access Location to disabled, needs to uLocation be nil.
default: // But don't stop update location, you can't come back when user granted permission to access Location.
uLocation = nil;
break;
}
}
<<--
posted by
Saturn on Mon 14 Apr 2014 at 17:44 with 0 comments