0
votes

I've been trying to reproduce this Animate a view zoom-bouncing in? in Monotouch but I hit an exception and I don't know what to do... these statics methods are in a utility class. An exception is raised on the sending the message to the first selector.

MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[MainScreen bounce1AnimationStopped]: unrecognized selector sent to instance 0x13908570 at at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSend_IntPtr_IntPtr (intptr,intptr,intptr,intptr) at AnimationManager.BounceAppear (MonoTouch.UIKit.UIViewController container, MonoTouch.UIKit.UIView view, Double duration) [0x0003a]

    public static void BounceAppear(UIViewController container, UIView view, double duration = 0.5)
    {
        view.Transform = CGAffineTransform.MakeScale(0.001f, 0.001f);
        UIView.BeginAnimations(null);
        UIView.SetAnimationDuration(0.3f/1.5f);
        UIView.SetAnimationDelegate(container);
        var selector = new MonoTouch.ObjCRuntime.Selector("bounce1AnimationStopped");
        Messaging.void_objc_msgSend_IntPtr_IntPtr(container.Handle, selector.Handle, container.Handle, view.Handle);
        UIView.SetAnimationDidStopSelector(selector);
        view.Transform = CGAffineTransform.MakeScale(1.1f, 1.1f);
        UIView.CommitAnimations();
    }

    [Export("bounce1AnimationStopped:forView")]
    public static void Bounce1AnimationStopped(UIViewController container,UIView view)
    {
        Console.WriteLine("Bounce1AnimationStopped");
        UIView.BeginAnimations(null);
        UIView.SetAnimationDuration(0.3f/2.0f);
        UIView.SetAnimationDelegate(container);
        var selector = new MonoTouch.ObjCRuntime.Selector("bounce2AnimationStopped");
        Messaging.void_objc_msgSend_IntPtr_IntPtr(container.Handle, selector.Handle, container.Handle, view.Handle);
        view.Transform = CGAffineTransform.MakeScale(0.9f,0.9f);
        UIView.CommitAnimations();
    }

    [Export("bounce2AnimationStopped:forView")]
    public static void Bounce2AnimationStopped(UIViewController container, UIView view)
    {
        Console.WriteLine("Bounce2AnimationStopped");
        UIView.BeginAnimations(null);
        UIView.SetAnimationDuration(0.3f/2.0f);
        view.Transform = CGAffineTransform.MakeIdentity();
        UIView.CommitAnimations();
    }
1

1 Answers

0
votes

Ok I forgot to register my class and have its reference pass to the messaging function

private static IntPtr class_ptr = Class.GetHandle("animationManager");

and then

Messaging.void_objc_msgSend_IntPtr_IntPtr(class_ptr, selector.Handle, container.Handle, view.Handle);