多个regionDidChangeAnimated调用-什么给出了?
我在 UITableView 中有一个 MKMapView 作为自定义单元格(不要问;) - 不知道它是否真的重要),为此我注册了一个 RegionDidChangeAnimated 委托方法。当 UITableView 加载时,此方法会被调用三次 - 一次使用实际区域,然后再使用两次远离的区域。在模拟器中,我始终得到一个中心区域(+37.43997405,-97.03125000)。在设备上,它似乎取决于位置管理器报告的位置,该位置管理器初始化地图视图。
为什么我收到三个regionDidChangeAnimated 调用?为什么最后两个的中心坐标偏离了?
这是我用来获取中心坐标的代码:
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
CLLocation *l = [[CLLocation alloc] initWithLatitude:self.mapView.centerCoordinate.latitude longitude:self.mapView.centerCoordinate.longitude];
(....)
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.
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];
(....)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经在自定义表格视图单元格内设置了地图视图,并将该单元格添加到表格视图中(尽管地图视图在何处/如何显示绝对不重要)。
我没有看到任何对
regionDidChangeAnimated:
委托方法的意外调用。仅当出现以下情况时,我才会看到对此方法的调用:
您确定看到了意外调用吗?您没有使用代码来设置地图的区域(中心/跨度)?
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).
I do not see any unexpected calls to the
regionDidChangeAnimated:
delegate method.I see calls to this method only when:
Are you sure that you are seeing unexpected calls? You are not using code to setup the region (center/span) of the map?