无法为自定义视图设置动画
我正在尝试使用以下代码对我的自定义视图的移动进行动画处理(我从 Apple 自己的文档中的 Objective-C 进行的最佳翻译)
var animDict = new NSMutableDictionary ();
animDict [NSViewAnimation.TargetKey] = this.View;
animDict [NSViewAnimation.StartFrameKey] = NSValue.FromRectangleF (this.View.Frame);
animDict [NSViewAnimation.EndFrameKey] = NSValue.FromRectangleF (new RectangleF (0, 150 * index, 400, 150));
var theAnim = new NSViewAnimation ();
theAnim.SetValuesForKeysWithDictionary (animDict);
theAnim.Duration = 2;
theAnim.StartAnimation ();
但是在运行应用程序时出现以下运行时错误:2011-05-08 00:53:30.827 EpisodeNext[61715:613] [ setValue:forUndefinedKey:]:此类对于键 NSViewAnimationTargetKey 不符合键值编码。
知道我做错了什么吗?谢谢!
I'm trying to animate the movement of a custom view of mine using the following code (my best translation from objective-c from Apples own documents)
var animDict = new NSMutableDictionary ();
animDict [NSViewAnimation.TargetKey] = this.View;
animDict [NSViewAnimation.StartFrameKey] = NSValue.FromRectangleF (this.View.Frame);
animDict [NSViewAnimation.EndFrameKey] = NSValue.FromRectangleF (new RectangleF (0, 150 * index, 400, 150));
var theAnim = new NSViewAnimation ();
theAnim.SetValuesForKeysWithDictionary (animDict);
theAnim.Duration = 2;
theAnim.StartAnimation ();
However I get the following run-time error when running the app: 2011-05-08 00:53:30.827 EpisodeNext[61715:613] [ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key NSViewAnimationTargetKey.
Any idea what I'm doing wrong? Thanx!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法使用
SetValuesForKeysWithDictionary
方法将动画键传递给NSViewAnimation
实例。您必须使用 NSViewAnimation(NSDictionary[] viewAnimations) 构造函数来传递动画字典。
You cannot use the method
SetValuesForKeysWithDictionary
to pass the animation keys to theNSViewAnimation
instance.You must use the
NSViewAnimation(NSDictionary[] viewAnimations)
constructor to pass the animation dictionary.// 为第一个视图创建属性字典。
// Create the attributes dictionary for the first view.