正在加载 mkannotationview 的附件标注视图

发布于 2024-08-03 19:39:58 字数 215 浏览 2 评论 0原文

我有一个地图注释视图,其中包含一个 rightcallout 按钮,该按钮加载一个 UIViewController 类的附件视图。我正在使用可重复使用的注释,但我想知道如何将更新的信息传递给我的 UIViewController 类。假设我有 2 个字符串值,它们在我的视图中映射到 2 个 UILabel。在初始附件视图已作为可重复使用的视图加载到内存中后,如何更新这些值?

任何帮助将不胜感激。

I have a map annotation view that contains a rightcallout button which loads an accessory view which is a UIViewController class. I am using resuable annotations, but am wondering how I can pass updated information to my UIViewController class. Let's say I have 2 string values which map to 2 UILabels on my view. How can I update those values after the initial accessory view has already been loaded into memory as a resusable view?

Any help would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

陪你搞怪i 2024-08-10 19:39:58

您需要在获取更新的对象中维护对 UILabels 的引用,然后使用 setTitle: (我认为)来更新标签。

You'll need to maintain a reference to the UILabels in the object that gets the update, and then use setTitle: (I think) to update the labels.

夏末 2024-08-10 19:39:58

在注释子类中,您需要重写 setTitle 方法,以将更改发送到子类所持有的 UIViewController 类的实例。或者,您可以设置注释子类以接收通知(来自 NSNotificationCenter),并在收到通知后更新 UIViewController 类的标题和实例。

如果您不熟悉 NSNotifications,那么这里有一个快速参考。我用它们来更新我的注释。
NSNotification 示例

In your annotation subclass you need to override the setTitle method to send the changes to the instance of your UIViewController class that your subclass is holding. Or, you could setup your annotation subclass to receive notifications (from NSNotificationCenter), and upon receiving a notification, update the title and the instance of your UIViewController class.

If you are unfamiliar with NSNotifications, then here is a quick reference. I used these to keep my annotations updated.
NSNotification Example

独自唱情﹋歌 2024-08-10 19:39:58

尝试使用 MKMapViewDelegate 方法:

-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control;

当用户点击注释视图的附件按钮之一时,将调用此方法。假设您的 MKMapViewDelegate 也是可以访问您的附件视图的 UIViewController。

Try using the MKMapViewDelegate method:

-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control;

This method is called when a user tapped one of the annotation view’s accessory buttons. Assuming that your MKMapViewDelegate is also the UIViewController that can access your accessory view.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文