1

我试图弄清楚如何有一个观点。我们称它为ThirdView。当用户单击SecondView上的特定按钮时,它应该从屏幕底部向上滑动。

4

2 回答 2

4

您需要在 SecondView 中创建 ThirdView 并将其呈现为模态视图,并在构造函数中传入 secondView。这将是按照您想要的方式对其进行动画处理的最简单方法。

var thirdView = new ThirdView(secondView);
this.PresentModalViewController(thirdView, true);

在您的第三个视图中,您需要调用传入的 SecondView 并调用:

secondView.DismissModalViewControllerAnimated(true);
于 2010-01-19T18:46:41.067 回答
1

这是一个完整的工作示例。这比chrisntr 的回答简单一点……尽管上面的例子是我用来弄清楚一切的。

这种方法最酷的地方在于,对于艺术定制 UI(比如我为游戏构建的 UI),没有现成的 UI 元素,如 TabBar、导航栏等。最具创意的应用程序没有t 使用标准 UI 的东西。

在您的main.cs文件中,在您的 finishedlaunching 块中:

ViewController myUIV = new ViewController();
window.AddSubview(myUIV.View);
window.MakeKeyAndVisble();

然后在一个新的代码文件中添加以下代码:

using System;
using System.Drawing;
using MonoTouch.UIKit;

namespace AnimationTest
{

    public class ViewController : UIViewController
    {
        UIButton uib = new UIButton(new RectangleF(100, 100, 40, 40));
        public override void ViewDidLoad()
        {
            Console.WriteLine("UI1");
            this.View.BackgroundColor = UIColor.Blue;
            uib.BackgroundColor = UIColor.White;
            uib.TouchUpInside += delegate {
                Console.WriteLine("Hey!");
                var vc2 = new SecondController();
                PresentModalViewController(vc2, true);
            };
            this.View.AddSubview(uib);
            base.ViewDidLoad();
        }
    }

    public class SecondController : UIViewController
    {
        UIButton uib = new UIButton(new RectangleF(100, 100, 40, 40));
        public override void ViewDidLoad()
        {
            this.View.BackgroundColor = UIColor.White;
            uib.BackgroundColor = UIColor.Red;
            uib.TouchUpInside += delegate {
                this.DismissModalViewControllerAnimated(true);
            };

            this.View.AddSubview(uib);
            base.ViewDidLoad();
        }
    }
于 2011-07-09T11:59:53.000 回答