根据苹果文档调用 visibleMapRect 应该返回 MKMapRect 的实例,但我得到一个 MKCoordinateRegion 代替。
class MyMapController < UIViewController
def loadView
super
self.view = MKMapView.alloc.init
view.delegate = self
end
def viewDidLoad
region = MKCoordinateRegionMake(
CLLocationCoordinate2D.new(20.7103500366211, -101.607849121094),
MKCoordinateSpanMake(18, 18)
)
view.setRegion region, animated: false
end
def mapView map, regionDidChangeAnimated: animated
puts map.visibleMapRect.inspect
# prints => <MKCoordinateRegion center=#<CLLocationCoordinate2D latitude=47967664.0 longitude=106401408.0> span=#<MKCoordinateSpan latitudeDelta=20971520.0 longitudeDelta=24051712.0>>
end
end