Hey there,

I am having some troubles with a Loading View being called late when
trying to call it from DidSelectAnnotationView in my Delegate for my
MapView.

So let me explain what I am trying to do:

I have a TabBarController, which has some tabs in it, one of them
being a Controller with a MapView in it, another with a Scroll View
displaying some elaborate data about the annotations. This all works
fine, but because of loading the data on that Scroll View takes a long
time first time loading it I want to display a Loading View, and when
everything is initialized in the Scroll View I will dismiss that
Loading View. This Loading View should show up when pressing an
Annotation on the map or when pressing the TabBar Item for the
Controller which takes a long time to load. Currently I am trying with
the Annotations first.

So my Loading View is resided in the AppDelegate so I can call it from
everywhere and dismiss it from everywhere (this works fine, I am using
it in other parts of my code as well).

Now when I call the method displaying the Loading View it gets shown
after the tab with the Scroll View is selected. Here is what I am
doing in my Delegate:

                public override void DidSelectAnnotationView (MKMapView mapView,
MKAnnotationView view)
                {
                        if (view.Annotation is MapAnnotation)
                        {
                                //Show Loading View
                                
((AppDelegate)UIApplication.SharedApplication.Delegate).ShowProgressBar();
                                var mapAnnotation = view.Annotation as 
MapAnnotation;
                                
                                var inventory = ViewModelFactory.Inventory;
                                inventory.SelectedLocation = 
mapAnnotation.Location;
                                
                                //Go to the LocationsScrollViewController
                                foreach (var vc in 
mapViewController.TabBarController.ViewControllers)
                                {
                                        if (vc is UINavigationController)
                                        {
                                                var topCont = (vc as 
UINavigationController).TopViewController;
                                                if (topCont is 
LocationsScrollViewController)
                                                        
((LocationsScrollViewController)topCont).InvokeScrollToSelectedLocation
= true;
                                        }
                                }
                                
                                //Deselect the annotation, otherwise this 
method will not be
triggered when pushing the annotation again!
                                foreach (MKAnnotation an in 
mapView.SelectedAnnotations)
                                        mapView.DeselectAnnotation(an, false);
                                
                                
mapViewController.TabBarController.SelectedIndex = 1;
                        }
                }

My Loading View is just a view with a progress indicator and a label
which I bring to front.

So what happens here is that it switches to the Tab I want to show and
THEN showing the Loading View. I have tried invoking it on the main
thread as well. Though I suspect that it is already there and the main
thread is being blocked by selecting the index on the TabBarController
as it might have a higher priority, therefore it completes after the
tab has been selected and hence the ProgressBar is shown too late.

Do you have any ideas how I can make sure the Loading View is
displaying before the tab is switched?
-- 
Med Venlig Hilsen / With Best Regards
Tomasz Cielecki
http://ostebaronen.dk
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to