Loading annotations from url using background thread. Pins doesn't show before moving or scaling mapView

前端 未结 1 490
面向向阳花
面向向阳花 2021-01-22 17:10

I load annotations from url using background thread. Pins doesn\'t show before I move or scale mapView. How can I update my view?

My viewDidAppear

- (voi         


        
相关标签:
1条回答
  • 2021-01-22 17:43

    You are updating the UI from a non UI - Thread this will not work

    You will have to call segments of code that update your ui inside the UIThread Block as following:

    For example

    [mapView removeAnnotations:annotationsOnMap];
    

    must be called in UI-Thread

       dispatch_async(dispatch_get_main_queue(), ^{
            //Update UI if you have to
            [mapView removeAnnotations:annotationsOnMap];
        });
    

    Please note that you have to call all your UI updates inside the main_queue thread

       dispatch_async(dispatch_get_main_queue(), ^{
            //All UI updating code must come here
        });
    
    0 讨论(0)
提交回复
热议问题