我正在尝试向我的ViewController添加一个地图,但是它在初始化方法上崩溃了。这是我的代码:
在TAMap.h中:
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
@interface TAMap : UIViewController<MKMapViewDelegate>
@property (nonatomic, strong) MKMapView *mapView;
@end在TAMap.m中:
@implementation TAMap
@synthesize mapView = _mapView;
- (void)viewDidLoad {
[super viewDidLoad];
// Crashes here:
self.mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];我使用的是ARC,我的代码似乎是完全通用的。我环顾四周,到处都是添加地图视图的相同代码。然而,它与EXE_BAD_ACCESS一起崩溃了。我遗漏了什么?
发布于 2016-07-07 01:24:39
我的工作代码:
- (void)viewDidLoad
{
[super viewDidLoad];
MKMapView *mapView = [[MKMapView alloc] initWithFrame:self.view.frame];
[self.view addSubview:mapView];
}https://stackoverflow.com/questions/20175491
复制相似问题