2012-02-14 61 views
1

我是MonoTouch的新手,因此MonoTouch.Dialog。使用Elements API,我創建了一個帶有兩個按鈕「帳戶」和「聯繫人」的簡單視圖。使用MonoTouch.Dialog搜索視圖

public override bool FinishedLaunching (UIApplication app, NSDictionary options) 
{ 
    _window = new UIWindow(UIScreen.MainScreen.Bounds); 

    _rootElement = new RootElement("Sample") 
    { 
     new Section() 
     { 
      new StringElement ("Accounts", delegate { ElementTapped(); }), 
     }, 
     new Section() 
     { 
      new StringElement ("Contacts", delegate { ElementTapped(); }), 
     } 
    }; 

    _rootVC = new DialogViewController(_rootElement); 
    _nav = new UINavigationController(_rootVC); 
    _window.RootViewController = _nav; 

    _window.MakeKeyAndVisible(); 

    return true; 
} 

一旦我點擊任一按鈕,我想調出一個新的視圖來搜索。我知道我必須創建一個新的DialogViewController並將EnableSearch設置爲true,但是如何將其添加到delegate內的我的NavigationController

謝謝。

回答

1

對於「帳戶」和「聯繫人」使用新的「rootElement的」您已經配置按需創建嵌套DialogViewController:

new RootElement ("Accounts", x => { 
    return new DialogViewController (....) { 
      EnableSearch = true 
    } 
} 
+0

完美,謝謝。 – dewed 2012-02-15 22:53:58