开发者

iOS MKMapView regionDidChangeAnimated visibleMapRect issue

开发者 https://www.devze.com 2023-03-23 05:33 出处:网络
Ok, I know I must be doing something wrong, but darned if I can figure it out, Basicall开发者_Python百科y I am trying to get the VisibleMapRect in the regionDidChangeAnimated call, but it appears as

Ok, I know I must be doing something wrong, but darned if I can figure it out,

Basicall开发者_Python百科y I am trying to get the VisibleMapRect in the regionDidChangeAnimated call, but it appears as though this call is being fired before the value is actually being set, because the mapView.visibleMapRect value is NULL the first time it is called.

Attepting to do a comparison between mapView.visibleMapRect to nil, is invalid operand to binary expression (MKMapRect to void*)

NSLog(@"VISIBLE MAP RECT %d",mapView.visibleMapRect);  

Shows 0 every time.

NSLog(@"Visible Map Rect %@",mapview.visibleMapRect)

show (null) every time.

So what do I do? How the heck to I test around this case? Comparing to nil isn't acceptable. I know there must be a way to handle this, but I am flumoxed at the moment.


The visibleMapRect property is of type MKMapRect which is a struct so %d and %@ won't work on the struct.

You need to either log the individual fields within the MKMapRect or use the MapKit function MKStringFromMapRect:

NSLog(@"Visible Map Rect %@",MKStringFromMapRect(mapView.visibleMapRect));
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号