WiFi和Sim网络停止运行我的iPhone应用程序
问题描述:
当我在iPhone上运行我的应用程序进行测试时,SIM和WiFi网络正在连接和断开连接。
但在正常情况下运行其他应用程序它工作正常吗?WiFi和Sim网络停止运行我的iPhone应用程序
我在我的应用程序中使用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
答
检查任何其他地图应用程序在设备上;如果同样的问题仍然存在,那么您的设备可能有问题。
如果在这个应用程序中发生同样的问题,(这是你的情况);由Iphone提供的AND MAP不会产生问题。
那么,考虑检查相同的应用程序,你从AppStore下载用于检查目的,在其他设备上,看看是否仍然存在相同的问题。
如果问题没有存在于其他设备上,那么,您的设备是有问题的。 如果问题确实存在于其他设备上,那么,您写的代码是有问题的。
+1
thanx解决方案我认为我的设备中存在一些问题。 – abhi1989 2013-03-20 07:15:10
如果没有人看到代码,有人会知道这是“代码问题”吗? – Adam 2013-03-19 12:11:08
请提供更详细的信息。 – 2013-03-19 12:15:15
如果仅在运行应用程序时发生这种情况,那么问题出现在代码中,否则设备有问题。 – 2013-03-19 12:50:54