最近开发出的一套系统。关于定位模块有问题,直接上源代码(ios7SDK).h文件
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#import <MapKit/MapKit.h>@interface BIDCheckInViewController : UIViewController<CLLocationManagerDelegate, MKMapViewDelegate, UIAlertViewDelegate>
@property (weak, nonatomic) IBOutlet MKMapView *mapView;@end.m文件
#import "BIDCheckInViewController.h"
#import "MRProgress.h"@interface BIDCheckInViewController ()
@property (copy, nonatomic) NSString *userName;
@property (copy, nonatomic) NSString *phoneNumber;
@property (strong, nonatomic) UIAlertView *phoneNumberView;
@property (strong, nonatomic) UIAlertView *checkInAlertView;
@property (strong, nonatomic) UIAlertView *checkInSuccessView;
@property (strong, nonatomic) UIAlertView *mapFailAlertView;
@property (strong, nonatomic) UIBarButtonItem *checkInBtn;
@end@implementation BIDCheckInViewController- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.mapView.delegate = self;
    self.mapView.userLocation.subtitle = @"位置解析中...";
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    NSDictionary *userInfo = [userDefaults dictionaryForKey:@"userInfo"];
    NSDictionary *userPhoneNumber = [userDefaults dictionaryForKey:@"userPhoneNumber"];
    self.userName = [userInfo objectForKey:@"UserName"];
    if ([[userPhoneNumber objectForKey:@"userName"] isEqualToString:self.userName]) {
        self.phoneNumber = [userPhoneNumber objectForKey:@"phoneNumber"];
    }
    
    UIBarButtonItem *checkInBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(checkIn)];
    checkInBtn.enabled = NO;
    self.navigationItem.rightBarButtonItem = checkInBtn;
    self.checkInBtn = checkInBtn;
    MRProgressOverlayView *hud =  [MRProgressOverlayView showOverlayAddedTo:self.view animated:YES];
    hud.mode = MRProgressOverlayViewModeIndeterminateSmallDefault;
    hud.titleLabelText = @"定位中...";}- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
    CLLocationCoordinate2D center = userLocation.location.coordinate;
    MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(center, 1000.0, 1000.0);
    CLGeocoder *geocoder = [[CLGeocoder alloc] init];
    NSLog(@"ssss");
    [geocoder reverseGeocodeLocation:userLocation.location completionHandler:^(NSArray *places, NSError *error) {
        NSString *message;
        if (error == nil &&[places count] > 0){
            CLPlace *place = [places objectAtIndex:0];
            NSString *formattedAddress = [[place.addressDictionary objectForKey:@"FormattedAddressLines"]componentsJoinedByString:@" "];
            mapView.userLocation.subtitle = formattedAddress;
            self.checkInBtn.enabled = YES;
        }
        else if (error == nil && [places count] == 0){
            message = @"未能确定您的位置";
            mapView.userLocation.subtitle = message;
            NSLog(@"error:%@", message);
        }
        else if (error != nil){
            message = @"位置解析出错";
            mapView.userLocation.subtitle = message;
            NSLog(@"error:%@", message);
        }
    }];
    
    [self.mapView selectAnnotation:self.mapView.userLocation animated:YES];
    [mapView setRegion:region animated:YES];
    [MRProgressOverlayView dismissAllOverlaysForView:self.view animated:YES];
//    self.mapView.showsUserLocation = NO;
}-(void)mapViewDidFailLoadingMap:(MKMapView *)mapView withError:(NSError *)error
{
    NSLog(@"%@", [error localizedFailureReason]);
    NSString *message = @"mapview载入出错,请检查您的网络连接是否正常!";
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:message delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
    alertView.delegate = self;
    [alertView show];
    self.mapFailAlertView = alertView;
    [MRProgressOverlayView dismissAllOverlaysForView:self.view animated:YES];
}-(void)mapView:(MKMapView *)mapView didFailToLocateUserWithError:(NSError *)error
{
    NSLog(@"%@", [error localizedDescription]);
}-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
    NSLog(@"%@", [error localizedDescription]);
}-(void)locationManager:(CLLocationManager *)manager monitoringDidFailForRegion:(CLRegion *)region withError:(NSError *)error
{
    NSLog(@"%@", [error localizedDescription]);
}-(void)locationManager:(CLLocationManager *)manager rangingBeaconsDidFailForRegion:(CLBeaconRegion *)region withError:(NSError *)error
{
    NSLog(@"%@", [error localizedDescription]);
}
/*
#pragma  - Navigation// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/- (void)checkIn
{
    NSString *message = [NSString stringWithFormat:@"%@", self.mapView.userLocation.subtitle];
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"您当前位置:" message:message delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定打卡", nil];
    self.checkInAlertView = alertView;
    [alertView show];
}-(void)submitDataToServer
{
    if (self.phoneNumber == nil || self.phoneNumber.length <= 0) {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请输入本机号码" message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
        UITextField *textField = [alertView textFieldAtIndex:0];
        //        textField.delegate = self;
        textField.keyboardType = UIKeyboardTypePhonePad;
        textField.clearButtonMode = UITextFieldViewModeWhileEditing;
        //        textField.returnKeyType = UIReturnKeyJoin;
        self.phoneNumberView = alertView;
        [alertView show];
        return;
    }
    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
    MRProgressOverlayView *hud =  [MRProgressOverlayView showOverlayAddedTo:self.navigationController.view animated:YES];
    hud.mode = MRProgressOverlayViewModeIndeterminateSmallDefault;
    hud.titleLabelText = @"提交中...";
    
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    CLLocationCoordinate2D center = self.mapView.userLocation.location.coordinate;
    NSString *location = [NSString stringWithFormat:@"%f:%f", center.longitude, center.latitude];
    NSDictionary *params = @{@"userName": self.userName, @"location":location, @"realAddress": self.mapView.userLocation.subtitle, @"phoneNumber": self.phoneNumber};
    NSLog(@"%@", [params description]);
    [manager GET:@"http://XXXXXXXXXXXXXXXXXXXXXXXXX.ashx" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSString *message;
        NSLog(@"JSON: %@", responseObject);
        if ([[responseObject objectForKey:@"IsSuccessfully"] boolValue] != NO) {
            message = @"操作已成功!";
            UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:message message:@"点击确定返回上一级菜单" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
            self.checkInSuccessView = alertView;
            [alertView show];
        }else{
            message = [responseObject objectForKey:@"ErrorMessage"];
            UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:message delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
            [alertView show];
        }
        
        [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
        [MRProgressOverlayView dismissOverlayForView:self.navigationController.view animated:YES];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:[error localizedDescription] delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alertView show];
        
        [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
        [MRProgressOverlayView dismissOverlayForView:self.navigationController.view animated:YES];
    }];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex != [alertView cancelButtonIndex]) {
        if ([alertView isEqual:self.phoneNumberView]) {
            NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
            UITextField *textField = [alertView textFieldAtIndex:0];
            NSDictionary *userPhoneNumber = @{@"userName": self.userName, @"phoneNumber": textField.text};
            [userDefaults setObject:userPhoneNumber forKey:@"userPhoneNumber"];
            [userDefaults synchronize];
            self.phoneNumber = textField.text;
            [self submitDataToServer];
        }else if ([alertView isEqual:self.checkInAlertView]){
            [self submitDataToServer];
        }
    }else{
        if ([alertView isEqual:self.checkInSuccessView]) {
            [self.navigationController popViewControllerAnimated:YES];
        }
        
        if ([alertView isEqual:self.mapFailAlertView]) {
            [self.navigationController popViewControllerAnimated:YES];
        }
    }
}
@end
问题:部分移动iphone在有网络的情况下会一直【位置解析中.....】无法得到地址。请大侠们帮我看看到底代码有什么问题