2013-04-04 63 views
0
使用选择器和消息绑定问题

我一直在试图重现此Animate a view zoom-bouncing in? 在MonoTouch的,但我打了一个例外,我不知道该怎么办......这些 静态方法是一个实用工具类。 将消息发送到第一个选择器时引发异常。在MonoTouch的

MonoTouch.Foundation.MonoTouchException:抛出了Objective-C异常。名称:NSInvalidArgumentException原因: - [MainScreen bounce1AnimationStopped]:无法识别的选择发送到实例0x13908570 处(包皮管理到本机)MonoTouch.ObjCRuntime.Messaging:void_objc_msgSend_IntPtr_IntPtr(IntPtr的,IntPtr的,IntPtr的,IntPtr的) 在AnimationManager.BounceAppear( MonoTouch.UIKit.UIViewController容器,MonoTouch.UIKit.UIView视图,双持续时间)[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(); 
    } 

回答

0

确定我忘记登记自己的类和具有其基准通行到消息收发功能

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

然后

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