从另一个视图中的 MKMapView 中删除注释
我有两种看法。第一个是带有一些注释的 MKMapView
。单击 UIButton
会将第二个视图推送到堆栈上。它有一个 UITableView
,其中包含与地图注释相对应的注释列表。那么,当您单击删除按钮时,如何调用另一个视图中的 MKMapView
,以便删除注释。我的 MKMapView 是在我的应用程序委托以及我当前的类中声明的。我正在尝试使用以下内容,但它不起作用:
RideAppDelegate *appDelegate = (RideAppDelegate *)[[UIApplication sharedApplication] delegate];
Annotation *ano;
CLLocationCoordinate2D anoPoint;
anoPoint.latitude = [[eventToDelete valueForKey:@"latitude"] doubleValue];
anoPoint.longitude = [[eventToDelete valueForKey:@"longitude"] doubleValue];
ano = [[[Annotation alloc] init] autorelease];
ano.coordinate = anoPoint;
[appDelegate.ridesMap removeAnnotation: ano];
[appDelegate release];
我一定是尝试错误地访问其他视图的 MKMapView
吗?
I have two views. The first is a MKMapView
with some annotations. Clicking a UIButton
pushes a second view on the stack. This has a UITableView
with a list of annotations which correspond to the map annotations. So, when you click the delete button, how can I call my MKMapView
which is in another view, so that I can remove the annotation. My MKMapView
is declared in my app delegate, as well as my current class. I am trying to use the following, but it is not working:
RideAppDelegate *appDelegate = (RideAppDelegate *)[[UIApplication sharedApplication] delegate];
Annotation *ano;
CLLocationCoordinate2D anoPoint;
anoPoint.latitude = [[eventToDelete valueForKey:@"latitude"] doubleValue];
anoPoint.longitude = [[eventToDelete valueForKey:@"longitude"] doubleValue];
ano = [[[Annotation alloc] init] autorelease];
ano.coordinate = anoPoint;
[appDelegate.ridesMap removeAnnotation: ano];
[appDelegate release];
I must be trying to access the MKMapView
of my other view incorrectly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
self.ridesMap = [[MKMapView alloc] init]
或类似方法创建和分配的吗?(为什么要释放 appDelegate?您不拥有或保留它。)
self.ridesMap = [[MKMapView alloc] init]
or similar?(why release the appDelegate? You don't own or retain it.)