2

次のコードを使用して、私のカスタム ビューの動きをアニメーション化しようとしています (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 のキー値コーディングに準拠していません。 .

私が間違っていることは何か分かりますか?ありがとう!

4

2 に答える 2

3

SetValuesForKeysWithDictionaryメソッドを使用してアニメーション キーをNSViewAnimationインスタンスに渡すことはできません。

NSViewAnimation(NSDictionary[] viewAnimations)アニメーション ディクショナリを渡すには、コンストラクタを使用する必要があります。

于 2011-05-09T11:27:54.657 に答える
2

// 最初のビューの属性ディクショナリを作成します。

        NSMutableDictionary firstViewDict = new NSMutableDictionary ();


        //var firstViewRect = new NSDictionary[] { };
        firstViewDict [NSViewAnimation.TargetKey] = animateWindow;
        firstViewDict [NSViewAnimation.StartFrameKey] = NSValue.FromRectangleF (new RectangleF (1000, 300 , this.Frame.Width - 40, 0));
        firstViewDict [NSViewAnimation.EndFrameKey]  = NSValue.FromRectangleF (SettingNSWindow.Frame);


        //var NSDict = new NSDictionary[]{ };
        NSDictionary[] NSDict =  new NSDictionary[]{firstViewDict};

        //NSDict.Cast(NSMutableDictionary = (NSDictionary[])firstViewDict;

        NSViewAnimation theAnim = new NSViewAnimation(NSDict);

        //theAnim.SetValuesForKeysWithDictionary (firstViewDict);
        theAnim.Duration = 2;
        theAnim.StartAnimation ();
于 2014-02-21T22:51:18.930 に答える