我一直在努力重现这个Animate a view zoom-bouncing in? 在Monotouch,但我遇到了一个例外,我不知道该怎么做...... 这些静态方法属于实用类。 将消息发送到第一个选择器时会引发异常。
MonoTouch.Foundation.MonoTouchException:抛出Objective-C异常。名称:NSInvalidArgumentException原因: - [MainScreen bounce1AnimationStopped]:无法识别的选择器发送到实例0x13908570 at at(wrapper managed-to-native)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 :(得分:0)
好的,我忘了注册我的课程并将其参考传递给消息传递函数
private static IntPtr class_ptr = Class.GetHandle("animationManager");
然后
Messaging.void_objc_msgSend_IntPtr_IntPtr(class_ptr, selector.Handle, container.Handle, view.Handle);