2013-04-04 65 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);