2010-01-19 141 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(); 
    } 
} 
相關問題