当我在iPhone中运行我的应用程序进行测试时, SIM 和 WiFi 网络正在连接并再次断开连接。
但在正常情况下正在运行其他应用程序工作正常吗?
我在我的应用中使用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
答案 0 :(得分:0)
检查您设备上的任何其他地图应用;如果同样的问题仍然存在,那么您的设备可能会出现问题。
如果此应用中出现同样的问题,(您的情况); Iphone提供的AND MAP没有给出问题。
然后,考虑检查您从AppStore下载的用于检查目的的相同应用程序,在其他设备上查看是否仍存在同样的问题。
如果问题 存在于其他设备上,则设备会出现问题。 如果问题 存在于其他设备上,则您编写的代码存在问题。