在我的应用中,mapView
在无法加载地图时显示UIAlertView
。我在
- (void)mapViewDidFailLoadingMap:(MKMapView *)mapView withError:(NSError *)error {}
当我通过关闭WiFi在Simulator或我的iPhone中模拟这个时,我收到了消息。但它出现两次或更多次。如何防止此方法中的所有内容多次执行?
答案 0 :(得分:1)
-(void)mapViewDidFailLoadingMap:(MKMapView *)mapView withError:(NSError *)error
此函数可能会被多次调用检查此Apple Docs
This method might be called in situations where the device does not have access to the network or is unable to load the map data for some reason. It may also be called if a request for additional map tiles comes in while a previous request for tiles is still pending. You can use this message to notify the user that the map data is unavailable
检查多次调用它的确切原因。此外,您可以通过使用某些标志或使用UIAlertView属性visible
答案 1 :(得分:0)
您可以在显示uialertview之前使用[UIAlertView isVisible],这将阻止您在已经显示alertview时显示多个uialertview。