我在RubyMotion第一次嘗試一個簡單的應用程序。我只是希望能夠點擊一個按鈕,然後開始UINavigationController
rubymotion按鈕按下後如何啓動NavigationController
步驟: - 用戶按下一個按鍵 - 屏幕移動到左,新的導航開始
我可以,如果我開始這樣做精從第一個視圖本身導航,但我希望能夠按下按鈕啓動它。
這裏是我迄今爲止
的AppDelegate:
#below commented line starts the navigation from the first view
#navController = UINavigationController.alloc.initWithRootViewController(HomeController.alloc.init)
@window.rootViewController = HomeController.alloc.init
true
的HomeController:
def viewDidLoad
self.title = "ONE"
button = UIButton.buttonWithType(UIButtonTypeRoundedRect)
button.frame = [[15,300], [280,50]]
button.setTitle("Move to next view", forState: UIControlStateNormal)
button.addTarget(self,
action: "startNavigationOne:",
forControlEvents: UIControlEventTouchUpInside)
view.addSubview(button)
end
def startNavigationOne (sender)
#what can I do here to start the navigation?
末
在第3步,當我運行應用程序時,它已經在屏幕頂部有一個欄,表示它已經有導航。我不'想要這個。我希望只有當我點擊按鈕 – Anthony
纔會出現在頂部的欄,然後你需要寫這個[self.navigationController setNavigationBarHidden:YES animated:YES];顯示並[self.navigationController setNavigationBarHidden:NO animated:YES];隱藏 –
由於這不是Ruby代碼,它可以很容易地翻譯成紅寶石。關於這篇文章的好消息是self.pushViewController方法的正確用法。 –