I've a simply view controller with a MKMapView object inside, defined in this way:
Class declaration:
@interface GeoViewController : UIViewController <MKMapViewDelegate>
@property (nonatomic, strong) MKMapView* viewMap;
@end
Implementation:
@implementation GeoViewController
- viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
viewMap = [[MKMapView alloc] init];
MKCoordinateRegion worldRegion = MKCoordinateRegionForMapRect(MKMapRectWorld);
[viewMap setRegion:worldRegion animated:YES];
viewMap.pitchEnabled = YES;
viewMap.showsUserLocation = YES;
viewMap.delegate = self;
[self.view addSubview:viewMap];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
viewMap.showsUserLocation = NO;
self.viewMap.delegate = nil;
[self.viewMap removeFromSuperview];
}
- (void)resizeForOrientation:(BOOL)isLandscape withFrame:(CGRect)frame {
[super resizeForOrientation:isLandscape withFrame:frame];
const CGRect fullFrame = CGRectMake(0, 0, frame.size.width, frame.size.height);
viewMap.frame = fullFrame;
}
@end
First time that I present the view controller works. Then I navigate in my app and if I come back on GeoViewController, crash:
- no message error on console
- main.m is opened and report "Thread 1: EXC_BAD_ACCESS"
on debug navigator (left) I get error report on Thread 1:
EAGLContext_renderbufferStorageFromDrawable(EAGLContext*, objc_selector*, unsigned int, id)
Now, googling a lot, I can't find a working solution for me:
I also try on viewDidDisappear, but no way
[EAGLContext setCurrentContext:nil];
Seems crashing for this row:
viewMap.frame = fullFrame;
Any suggestion will be appreciated!
update
I receive other errors sometime in my test:
opengl thread conflict detected