2010-01-19 139 views

回答

4

您需要在SecondView中创建ThirdView,并将其作为在构造函数中传递给secondView的模态视图呈现。这将是以您喜欢的方式进行动画制作的最简单方法。

var thirdView = new ThirdView(secondView); 
this.PresentModalViewController(thirdView, true); 
在你的第三个观点

,你要调用SecondView传递和调用

secondView.DismissModalViewControllerAnimated(true); 

希望这有助于

ChrisNTR

+0

我不明白DismissModalViewControllerAnimated做什么。你可以解释吗? 另外,我认为这将在ViewDidLoad处理程序中完成? – 2010-01-24 03:21:40

1

这是一个完整的工作示例。这比上面的简单一点...虽然上面的例子是我用来把所有东西都弄清楚的东西。感谢chrisntr。

这种方法最酷的地方在于,对于一​​个艺术的自定义用户界面(比如我为游戏构建的用户界面),没有像TabBar,导航栏等现成的UI元素。最创意应用程序不使用标准的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(); 
    } 
} 
相关问题