多个regionDidChangeAnimated调用 - 什么给? [英] multiple regionDidChangeAnimated calls - what gives?

查看:130
本文介绍了多个regionDidChangeAnimated调用 - 什么给?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个UITableView中有一个MKMapView作为一个自定义单元格(不要问;) - 不知道它是否真的很重要),为此我注册了一个regionDidChangeAnimated委托方法。这个方法在加载UITableView时调用了三次 - 一次是实际的区域,然后是两次,一个区域是关闭的。在模拟器中,我始终得到一个中心区域(+37.43997405,-97.03125000)。在设备上,它似乎取决于位置管理器报告的位置,该位置管理器初始化地图视图。

I have a MKMapView inside a UITableView as a custom cell (don't ask ;) - don't know if it matters really), for which I register a regionDidChangeAnimated delegate method. This method gets called three times when the UITableView is loaded - once with the actual region and then two more times with a region that is way off. In the simulator, I consistently get a region with center (+37.43997405, -97.03125000). On the device, it seems to depend on the location reported by the location manager, which initializes the map view.

为什么我会收到三个regionDidChangeAnimated调用?为什么中间坐标是最后两个关闭的?

Why am I getting three regionDidChangeAnimated calls? And why are the center coordinates for the last two of them off?

这是我用来获取中心坐标的代码:

This is the code I use to get the center coordinates:

- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
    CLLocation *l = [[CLLocation alloc] initWithLatitude:self.mapView.centerCoordinate.latitude longitude:self.mapView.centerCoordinate.longitude];
(....)


推荐答案

I已经在自定义表格视图单元格内设置了一个地图视图,并将该单元格添加到了一个表格视图中(尽管它绝对不应该关注地图视图的显示位置)。

I have set up a map view inside a custom table view cell and added that cell to a table view (although it definitely should not matter where/how the map view is displayed).

我看不到任何对 regionDidChangeAnimated:委托方法的意外调用。

I do not see any unexpected calls to the regionDidChangeAnimated: delegate method.

我看到对此方法的调用只有在以下情况时:

I see calls to this method only when:


  1. 用户更改地图的位置/缩放比例,或
  2. 更改地图的中心/范围

您确定您看到意外呼叫吗?您没有使用代码来设置地图的区域(中心/跨度)?

Are you sure that you are seeing unexpected calls? You are not using code to setup the region (center/span) of the map?

这篇关于多个regionDidChangeAnimated调用 - 什么给?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆