Can somebody comment WHEN these problems with nested animations occur? I’m
animating controller views left and right in my own view controller
containment implementation (a split view clone) and have never seen these
problems when animating views manually.

However I noticed once that I got an exception that informed that a
transition to another controller cannot be started while one is still
running.

Where’s the difference between manual view animation and using controller’s
transitions?

 

René

 

Von: [email protected]
[mailto:[email protected]] Im Auftrag von Dean Cleaver
Gesendet: Samstag, 14. April 2012 02:23
An: [email protected]
Betreff: Re: [MonoTouch] Nested push animations

 

Worked it out in the end. You can do it this way:

 

using MonoTouch.UIKit;

 

namespace Your.Namespace

{

                    public class NavigationControllerDelegate :
UINavigationControllerDelegate

                    {

                                         public bool Transitioning = true;

                                         

                                        public override void
DidShowViewController (UINavigationController navigationController,
UIViewController viewController, bool animated)

                                         {

 
this.Transitioning = false;

                                         }

                    }

}

 

And do this on each PopViewControllerAnimated:

 

NavigationControllerDelegate navigationControllerDelegate = new
NavigationControllerDelegate();
 

navigationController.Delegate = navigationControllerDelegate;
navigationController.PopViewControllerAnimated(true);
 

while (navigationControllerDelegate.Transitioning)
    NSRunLoop.Current.RunUntil(DateTime.Now.AddMilliseconds(50));
 

navigationController.Delegate = null;
 

But rather than do that everywhere, I created this extension method (using
the above delegate class):

 

using System;
 
using MonoTouch.Foundation;
 
using Your.Namespace;
 
namespace MonoTouch.UIKit
{
                    public static class NavigationControllerExtension
                    {
                                        public static UIViewController
PopViewControllerAnimatedPause(this UINavigationController
navigationController, bool animated)
                                         {
                                                             if (animated)
                                                             {
 
NavigationControllerDelegate  existing = navigationController.Delegate ;
 
NavigationControllerDelegate navigationControllerDelegate = new
NavigationControllerDelegate();
 

 
navigationController.Delegate = navigationControllerDelegate;
 
UIViewController result =
navigationController.PopViewControllerAnimated(true);
 

 
while (navigationControllerDelegate.Transitioning)
 
NSRunLoop.Current.RunUntil(DateTime.Now.AddMilliseconds(50));
 

 
navigationController.Delegate = existing;
 

 
return result;
                                                             }
 
                                                             return
navigationController.PopViewControllerAnimated(false);
                                         }
                    }
}
 
 

Now all I have to do is call “PopViewControllerAnimatedPause(true);“ and
it’s all handled for me.

 

Dino

 

From: [email protected]
[mailto:[email protected]] On Behalf Of Dean Cleaver
Sent: Friday, April 13, 2012 1:42 PM
To: [email protected]
Subject: [MonoTouch] Nested push animations

 

Hi,

 

I’m getting some nested push animation errors when transitioning between
screens, and I’m not sure how I can prevent it nicely. Basically:

 

1.       I push a screen that the user fills in.

2.       I pop the screen animated.

3.       I call other code that depending on circumstances, may or may not
show a UIActionSheet or another UIView animated.

 

On showing the UIActionSheet or UIView I get the nested animation problems.

 

Now, I can pop the screen not animated in step 2, but it looks rather abrupt
if step 3 doesn’t show any other UI elements. What I’m looking for is a way
to detect that the pop in step 2 has completed before I continue with step 3
– is there an easy way to detect that its completed?

 

Dino

_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to