0
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation{
static int i=0;
if([self getCurrentLocation]==nil){
i++;
if(i>3){
[[self locationManager] stopUpdatingLocation];
useMyLocation = NO;
[self locationUpdated];
}
}else{
[self locationUpdated];
}
}
- (void)alertView:(UIAlertView *)anAlertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if(buttonIndex==1){
self.useMyLocation = YES;
[[self locationManager] startUpdatingLocation];
}else{ // buttonIndex==0
self.useMyLocation = NO;
[self locationUpdated];
}
這是IOS 4和5。我的問題一個工作代碼是,我不能讓位置工作在IOS 6應用程序不甚至要求用戶許可。閱讀後,這是我迄今嘗試過的:
CFBundleDisplayName解決方案。我的plist中已經有了CFBundleDisplayName。我嘗試刪除它並再次添加 - 不行。
設置位置管理的財產pausesLocationUpdatesAutomatically到沒有這樣的:
...
- (CLLocationManager *)locationManager{
if (locationManager != nil){
return locationManager;
}
CLLocationManager *tmp = [[CLLocationManager alloc] init];
tmp.pausesLocationUpdatesAutomatically = NO; //[email protected]#
[self setLocationManager:tmp];
[tmp release];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[locationManager setDelegate:self];
return locationManager;
}
我也讀到locationManager:didUpdateLocations:
,我不知道如何實現它在代碼,我也不確定這是否是解決方案。
是,這樣的:' - (無效)alertView:(UIAlertView中*)anAlertView clickedButtonAtIndex:(NSInteger的)buttonIndex { \t如果(buttonIndex == 1){ \t \t self.useMyLocation = YES; \t \t [[self locationManager] startUpdatingLocation]; \t} else {// buttonIndex == 0 \t \t self.useMyLocation = NO; \t \t [self locationUpdated]; \t} }' – Segev
@Sha,你應該更新你的問題來包含它 - 還有,這個函數是否會被調用來啓動位置管理器更新? – Joshua
在ios低於6 - 是的。在iOS 6上 - 我不知道,也沒有與iOS 6我可以調試的設備。我可以在模擬器上測試它嗎? (不管我用什麼版本的模擬器都不會調用該函數) – Segev