接手了一个比较老的flutter项目,SDK版本是2.0.6,其中iOS用到了RxMKMapView库,但是报错了,因为xcode都是及时更新的,所以会有不兼容情况。
1.第一个报错:
解决方法:
let selector: Selector
#if swift(>=5.7)
selector = #selector(
(MKMapViewDelegate.mapView(_:didAdd:))
as (MKMapViewDelegate) -> ((MKMapView, [MKAnnotationView]) -> Void)?
)
#else
selector = #selector(
(MKMapViewDelegate.mapView(_:didAdd:))!
as (MKMapViewDelegate) -> (MKMapView, [MKAnnotationView]) -> Void
)
#endif
let source = delegate.methodInvoked(selector).map { a in
return try castOrThrow([MKAnnotationView].self, a[1])
}
return ControlEvent(events: source)
2.第二个报错
解决方法:
let selector: Selector
#if swift(>=5.7)
selector = #selector(
(MKMapViewDelegate.mapView(_:didAdd:))
as (MKMapViewDelegate) -> ((MKMapView, [MKOverlayRenderer]) -> Void)?
)
#else
selector = #selector(
(MKMapViewDelegate.mapView(_:didAdd:))!
as (MKMapViewDelegate) -> (MKMapView, [MKOverlayRenderer]) -> Void
)
#endif
let source = delegate
.methodInvoked(selector)
.map { a in
return try castOrThrow([MKOverlayRenderer].self, a[1])
}
return ControlEvent(events: source)
记录开发中的一些小问题,有兴趣的朋友也可以把解决的bug方法发送给博主哦!