MKMapView 不接受注释

发布于 2024-08-22 03:34:52 字数 437 浏览 4 评论 0原文

这很难解释,所以请耐心等待……我正在使用一个我知道有效的例子。这是 Apress More iPhone 开发书中的 MapMe 章节。

我使用相同的代码,但我创建了一个 MapViewController 类来包含所有地图代码,并将笔尖中的视图插入为 MainViewController 视图的子视图。与我一起?

我的问题似乎是这样的:现在包含 MKMapView 对象的视图是 MainViewController 的子视图,它不想将注释对象添加到视图中。我可以更改 mapType 并启动 locationManager:didUpdateToLocation 来精确定位我的位置。事实上,它为我删除了默认的红色图钉。但我的自定义注释对象未通过。

请记住,直接从 MapViewController 运行此代码时效果很好。仅当我将视图作为另一个 ViewController 的子视图插入时,它才会中断。

This is hard to explain so bear with me ... I'm using an example that I know works. It's the MapMe chapter from the Apress More iPhone dev book.

I'm using the same code but I've created a MapViewController class to contain all the map code and am inserting the view from the nib as a subview of my MainViewController view. With me?

My problem seems to be this : now the view containing the MKMapView object is a subview of the MainViewController it doesn't want to add the annotation object into the view. I can change the mapType and can initiate the locationManager:didUpdateToLocation to pinpoint my location. Indeed it drops the default red pin for me. My custom annotation object is not passed though.

Remember, this code worked fine when run directly from the MapViewController. It only breaks when I insert the view as a subview of another ViewController.

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

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

发布评论

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

评论(1

隔纱相望 2024-08-29 03:34:52

好吧,我是个白痴...代表没有设置在 NIB 中...DOH!!!小学生的错误。吸取教训。

Ok, I'm an idiot ... the delegate wasn't set in the NIB ... DOH!!! Schoolboy error. Lesson learned.

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