-1

当我在 iPhone 中运行我的应用程序进行测试时,SIMWiFi网络一次又一次地连接和断开连接。
但是在正常情况下并运行其他应用程序它工作正常吗?

我在我的应用程序中使用 GPS 和地图服务。

1)代码问题?
2) iPhone 有问题?
3)其他?

    #import <UIKit/UIKit.h>
    #import <CoreLocation/CoreLocation.h>
    #import <MapKit/MapKit.h>

    @interface MainViewController : UIViewController<CLLocationManagerDelegate, 

    MKMapViewDelegate>
    @property (strong, nonatomic) IBOutlet UIView *mapView;
    @property (strong, nonatomic) CLLocationManager *locationManager;
    @property (strong, nonatomic) IBOutlet MKMapView *mkMap;
    @property (strong, nonatomic) CLLocation *myCurrentLocation;
    - (IBAction)mapView:(id)sender;
    - (IBAction)mapToMain:(id)sender;
    @end






    #import "MainViewController.h"
    #import <MapKit/MapKit.h>
    @interface MainViewController ()

    @end

    @implementation MainViewController
    @synthesize mapView;
    @synthesize mkMap;
    @synthesize myCurrentLocation;
    @synthesize locationManager;
    - (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 from its nib.


        //start core location services
        if(self.locationManager == nil)
        {
            locationManager=[[CLLocationManager alloc] init];

        }
        locationManager.delegate=self;
        locationManager.desiredAccuracy=kCLLocationAccuracyBestForNavigation;
        [locationManager startUpdatingLocation];
        mkMap.showsUserLocation=YES;
        myCurrentLocation=mkMap.userLocation.location;

    }


    #pragma mark- core location delgate method
    -(void) locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray         *)locations 
    {
        NSLog(@"locationUpdated");
        NSLog(@"%@",[locations lastObject]);
    }
    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }

    - (IBAction)mapView:(id)sender {

        [self.view addSubview:mapView];
    }
    - (IBAction)mapToMain:(id)sender {
        [mapView removeFromSuperview];
    }
    @end
4

1 回答 1

0

Check ANY OTHER Maps App on your device; if the same problem persists, then your device may have problem.

If same problem is occurring in this app, (Which is your case); AND MAP that is provided by Iphone is not giving the problem.

THEN, Consider checking the same App, you downloaded from AppStore for checking purpose, on some other device and see if the same problem persist.

If the problem does not exist on other devices then, your device is problematic. If the problem does exist on other devices then, code you wrote is problematic.

于 2013-03-20T07:08:05.993 回答