gpt4 book ai didi

objective-c - -[UIView setRegion :animated:]: unrecognized selector sent to instance

转载 作者:行者123 更新时间:2023-11-29 11:05:42 26 4
gpt4 key购买 nike

我是 Objective C 的初学者。我在导航 Controller 内选择 TableRow 后设置 Mapview。我收到此终止应用程序的错误。

-[UIView setRegion:animated:]: unrecognized selector sent to instance 0x806b2c0

这是我的 Mapview viewWillAppeer

- (void)viewWillAppear:(BOOL)animated {

CLLocationCoordinate2D zoomLocation;
zoomLocation.latitude = 39.281516;
zoomLocation.longitude= -76.580806;

if (CLLocationCoordinate2DIsValid(location)) {
MKCoordinateRegion mapRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, 0.5*METERS_PER_MILE, 0.5*METERS_PER_MILE);

[_mapView setRegion:mapRegion animated:YES];
} else {
NSLog(@"Invalid coordinates");
}
}

此文件的头文件导入了 mapkit 和 corelocation 并具有此属性。

@property (weak, nonatomic) IBOutlet MKMapView *mapView;

头文件包括 mapkit 和 coreelocation 并且使这个属性变强也没有改变任何东西。

最佳答案

发生这种情况是因为我之前在我的 LocateItemViewController(具有 map View 的 Controller )上连接了一个名为“mapView”的 socket ,并且从未从“Connections Inspector”中删除它。

see the greyed outlet named "view" under Outlets section, I had a similar one named mapView

在 Outlets 部分看到名为“view”的灰色 socket ,我有一个类似的名为 mapView

关于objective-c - -[UIView setRegion :animated:]: unrecognized selector sent to instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13719078/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com