UI Tab Bar mapView 核心数据更新后刷新

发布于 2024-12-10 02:46:27 字数 823 浏览 1 评论 0原文

我有一个有 3 个视图的应用程序。我正在使用选项卡栏控制器来选择视图。

我目前将地图设置为缩放到包含所有注释的最近位置。但是,当我更新视图一中的核心数据,然后选择选项卡 2 时,注释引脚保持不变。即使我退出应用程序,图钉颜色仍保持不变(它根据数据状态改变颜色)。我可以让它更新的唯一方法是放大,然后退出。

我尝试过的代码:

[mapView release];

[mapView setNeedsDisplay];

[mapView removeAnnotation:tempAnnotation];

[mapView addAnnotation:tempAnnotation];

CLLocationCooperative2D center = [mapView centerCooperative];

[mapView setCenterCooperative:center];

I甚至将地图集 FlyTo 坐标设置两次,一次放大得很远,然后再次设置为“正常”缩放级别。

有没有办法刷新 didFinishLoading 等上的视图?

我是否可以将这些代码片段之一放置在错误的位置?

我还释放了传递的数据等,

这只是选项卡栏缓存页面吗?有没有办法强制刷新地图?

谢谢! (我有点菜鸟,所以如果你能帮忙,请明确说明步骤以帮助我理解)

罗伯特

I have an app with 3 views. I am using a tab bar controller to select the views.

I currently have the map set to zoom to the closest location that includes all the annotations. However, when I update the core data in view one, and then select tab 2 but the annotation pin remains the same. Even if I quit the app the pin color reamins the same (it changes color based on data state). the only way I can get it to update, is to zoom far in, then back out.

code I have tried:

[mapView release];

and

[mapView setNeedsDisplay];

and

[mapView removeAnnotation:tempAnnotation];

[mapView addAnnotation:tempAnnotation];

and

CLLocationCoordinate2D center = [mapView centerCoordinate];

[mapView setCenterCoordinate:center];

I even set the map set flyTo the coordinates 2 times, once zoomed far in, then again at 'normal' zoom level.

Is there a way to refresh the view on didFinishLoading, etc?

Could I be placing one of these code snippets int he wrong place?

I am also releasing the passed data etc

is it just that the tab bar caches the page? is there a way to force a map refresh?

Thanks! (I am kind of a noob so if you can help, please be clear as to the steps to help me understand)

Robert

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

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

发布评论

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

评论(1

夜雨飘雪 2024-12-17 02:46:27

我也即将回答我自己的问题:

我看到了关于如何重置视图、重绘图层等的帖子。我对这门语言相当(不是新手)缺乏经验,所以我所做的是一种黑客攻击,但是有用。我希望你在必要时使用这个,但找到更好的解决方案。

视图控制器:

- (void)viewWillAppear:(BOOL)animated {

    [super viewWillAppear:animated];

    mapView.region = MKCoordinateRegionMakeWithDistance([mapView centerCoordinate],2587600.0, 2587600.0);

}

- (void)viewWillDisappear:(BOOL)animated {

    [super viewWillDisappear:animated];

    mapView.region = MKCoordinateRegionMakeWithDistance([mapView centerCoordinate],5.0, 5.0);
}

所以当视图离开时,嗯......视图,然后地图会放大得很远。当视图返回视图时,数据会重新加载,瞧。您的里程可能会有所不同,但这种方法非常适合我需要它做的事情。

而且这根本不是一个不和谐的效果。这是无缝的。从 UI 的角度来看,没有任何变化。

干杯!
罗伯特

I am about to answer my own question with this as well:

I saw posts on how to reset the view, redraw the layer etc. I am fairly (not new) inexperienced with the language, so what I have done is a hack, but it works. I hope you use this if you have to, but find a better solution.

View Controller:

- (void)viewWillAppear:(BOOL)animated {

    [super viewWillAppear:animated];

    mapView.region = MKCoordinateRegionMakeWithDistance([mapView centerCoordinate],2587600.0, 2587600.0);

}

- (void)viewWillDisappear:(BOOL)animated {

    [super viewWillDisappear:animated];

    mapView.region = MKCoordinateRegionMakeWithDistance([mapView centerCoordinate],5.0, 5.0);
}

So when the view leaves, well... view, then the map zooms really far in. When the view returns to view, the the data is reloaded and voila. Your mileage may vary, but this method works perfectly for what I need it to do.

And it is not a jarring effect at all. It is seamless. From a UI standpoint, nothing changes.

cheers!
Robert

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