iOS开发,地图大头针标记 选中状态 的正确处理办法(此解决方法适用于自带地图、高德地图、百度地图)

- (void)mapView:(MAMapView *)mapView didSelectAnnotationView:(MAAnnotationView *)view {

    NSLog(@"选中了标注%f, %f",view.annotation.coordinate.latitude, view.annotation.coordinate.longitude);

    WeakSelf;

    UIAlertController *alerController = [UIAlertController alertControllerWithTitle:@"导航" message:@"选择导航方式" preferredStyle:UIAlertControllerStyleActionSheet];

    UIAlertAction *action = [UIAlertAction actionWithTitle:@"高德地图" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

 

    }];

    UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"百度地图" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

        

    }];

    UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {

//        [view setSelected:NO animated:YES];       //有BUG

//        view.selected = NO;                       //有BUG

//        取消选中正确方式

        StrongSelf;

        for (id annotation in strongSelf.mapView.annotations) {

            [strongSelf.mapView deselectAnnotation:annotation animated:YES];

        }

    }];

    [alerController addAction:action];

    [alerController addAction:action1];

    [alerController addAction:action2];

    [self.navigationController presentViewController:alerController animated:YES completion:nil];

}

你可能感兴趣的:(iOS开发,地图大头针标记 选中状态 的正确处理办法(此解决方法适用于自带地图、高德地图、百度地图))