-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

デバイス上の他のマップアプリを確認してください。同じ問題が続く場合は、デバイスに問題がある可能性があります。

このアプリで同じ問題が発生している場合(これはあなたの場合です); そして、iPhoneによって提供されるMAPは問題を与えていません。

次に、他のデバイスで、目的を確認するためにAppStoreからダウンロードした同じアプリを確認し、同じ問題が続くかどうかを確認することを検討してください。

問題が他のデバイスに存在しない場合は、デバイスに問題があります。問題他のデバイスに存在する場合は、作成したコードに問題があります。

于 2013-03-20T07:08:05.993 に答える