Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如果在打开应用程序后直接输入mapview,iOS应用程序偶尔会崩溃_Ios_Objective C_Mkmapview - Fatal编程技术网

如果在打开应用程序后直接输入mapview,iOS应用程序偶尔会崩溃

如果在打开应用程序后直接输入mapview,iOS应用程序偶尔会崩溃,ios,objective-c,mkmapview,Ios,Objective C,Mkmapview,我已经创建了一个运行6.1版的iPhone应用程序。 在我的一个视图中,我使用了一个地图视图,包括注释钉、缩放到位置 如果所有其他视图都已首先打开且mapview未崩溃,则应用程序运行正常。 但是,如果我打开应用程序并转到mapview viewcontroller,应用程序将崩溃 此外,该应用程序只会在我的iPhone 4S设备上崩溃,而不会在控制器中崩溃 谁能帮帮我吗 致以最良好的祝愿 以下是我的mapview代码: @interface VisPaaKortViewControll

我已经创建了一个运行6.1版的iPhone应用程序。 在我的一个视图中,我使用了一个地图视图,包括注释钉、缩放到位置

如果所有其他视图都已首先打开且mapview未崩溃,则应用程序运行正常。 但是,如果我打开应用程序并转到mapview viewcontroller,应用程序将崩溃

此外,该应用程序只会在我的iPhone 4S设备上崩溃,而不会在控制器中崩溃

谁能帮帮我吗

致以最良好的祝愿

以下是我的mapview代码:

    @interface VisPaaKortViewController ()

@end

@implementation VisPaaKortViewController
@synthesize mapView;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.mapView.delegate = self;
    mapView.showsUserLocation = YES;




    // Do any additional setup after loading the view.


    // Create a view of the standard size at the top of the screen.
    // Available AdSize constants are explained in GADAdSize.h.
    bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];

    // Specify the ad's "unit identifier". This is your AdMob Publisher ID.
    bannerView_.adUnitID = @"my_publisher_id";

    // Let the runtime know which UIViewController to restore after taking
    // the user wherever the ad goes and add it to the view hierarchy.
    bannerView_.rootViewController = self;
    [self.view addSubview:bannerView_];


    //Placement of banner
    [bannerView_ setFrame:CGRectMake(0,
                                     362,
                                     bannerView_.bounds.size.width,
                                     bannerView_.bounds.size.height)];



    // Initiate a generic request to load it with an ad.
    [bannerView_ loadRequest:[GADRequest request]];


}


-(void) viewWillAppear:(BOOL)animated {
    [self performSelector:@selector(zoomInToMyLocation)
               withObject:nil
               afterDelay:0];
}





- (void)zoomInToMyLocation
{


    CLLocationCoordinate2D location;
    location.latitude = (double) 59.778747;
    location.longitude = (double) 9.292349;



    MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(location, 800, 800);
    [self.mapView setRegion:[self.mapView regionThatFits:region] animated:NO];


    // Add an annotation
    MKPointAnnotation *point = [[MKPointAnnotation alloc] init];
    point.coordinate = location;
    point.title = @"Text";
    point.subtitle = @"Text";

    [self.mapView addAnnotation:point];
    [self.mapView selectAnnotation:[[self.mapView annotations] objectAtIndex:0] animated:YES];

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

因为你没有提供太多的细节,我不得不猜测。我假设您使用ARC,我将尝试添加self.mapView.delegate=nil;使用您的dealloc方法

- (void)dealloc {
    self.mapView.delegate = nil;
}
MKMapViews委托声明为assign且不弱,这意味着当viewController已解除分配时,该委托仍可能被引用


如果不使用ARC,则仍应在dealloc中禁用mapView.delegate

显示崩溃时的错误。大多数时候,它都包含答案。这是我得到的错误:由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“无效区域”***第一次抛出调用堆栈:0x344fb2a3 0x3c22397f 0x344faf99 0x353283c9 0x353284e7 0x3532651d 0x35311e83 0x35311db7 0x353249e1 0x364e8ac7 0x3666BF 0x344f6aef 0x344efa79 0x34451b6b 0x3631f0ab 0x36740c2d 0x3630ca91 0x36306803 0x360b0d8b 0x360b0929 0x360b185d 0x360b1243 0x360b1051 0x360EB344DCD0x344ced17 0x34441ebd 0x34441d49 0x3801a2eb 0x36357301 0xf3be5 0x3c65ab20 libc++abi.dylib:lldb这是我得到的错误:由于未捕获的异常“NSInvalidArgumentException”终止应用程序,原因:“无效区域”***第一次抛出调用堆栈:0x344fb2a3 0x3c22397f 0x344faf99 0x353283c9 0x353284e7 0x3532651d 0x35311e83 0x35311db7 0x353249e1 0x364e8ac7 0x3666BF 0x344f6aef 0x344efa79 0x34451b6b 0x3631f0ab 0x36740c2d 0x3630ca91 0x36306803 0x360b0d8b 0x360b0929 0x360b185d 0x360b1243 0x360b1051 0x360EB344DCD0x344ced17 0x34441ebd 0x34441d49 0x3801a2eb 0x36357301 0xf3be5 0x3c65ab20 libc++abi.dylib:lldb