我有個簡單地查看控制器用的MKMapView對象的內部,以這種方式定義:的MKMapView與iOS 8碰撞
類聲明:
@interface GeoViewController : UIViewController <MKMapViewDelegate>
@property (nonatomic, strong) MKMapView* viewMap;
@end
實現:
@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
首先我介紹視圖控制器工作的時間。然後,我瀏覽我的應用程序,如果我回來GeoViewController,崩潰:
- 在控制檯上沒有消息錯誤
- main.m文件被打開,並報告「主題1:EXC_BAD_ACCESS」
上調試導航(左)我得到線程1錯誤報告:
EAGLContext_renderbufferStorageFromDrawable(EAGLContext *,objc_selector *,無符號整型,ID)
現在,谷歌搜索了很多,我不能給我找一個工作的解決方案:
我也嘗試viewDidDisappear,但沒辦法
[EAGLContext setCurrentContext:nil];
似乎崩潰了此行:
viewMap.frame = fullFrame;
任何建議將不勝感激!
更新
我收到其他錯誤某個時候在我的測試:
OpenGL的線程衝突檢測
可能是不相關的,但由於'viewMap'是一個屬性,你應該使用'的self.viewMap = ...'而不是僅僅'視圖地圖= ...'分配它。所以'viewMap = [[MKMapView alloc] init];'應該是'self.viewMap = [[MKMapView alloc] init];'。 – Anna