2013-02-13 106 views
1

我有一個視圖與表視圖和觸摸行我想導航到其他視圖。 一切都好,但按鈕,標籤和其他人沒有呈現在視圖上。iOS導航到其他視圖didSelectRowAtIndexPath

Storyboard

對於導航到其他視圖我用這個代碼:

GenderViewController *myController = [[GenderViewController alloc] initWithNibName:nil bundle:nil]; 

[self.navigationController pushViewController:myController animated:YES]; 
[myController release]; 

在哪裏可以是問題嗎?

謝謝!

+0

您正在使用storyborad嘗試使用prepareforseague .please與故事板教程交叉檢查 – Vinodh 2013-02-13 10:30:28

+0

我看到此代碼中沒有錯誤。 – 2013-02-13 10:30:55

回答

1

您使用故事板,因此請爲您的viewController使用segue或標識符。

GenderViewController *myController = [[GenderViewController alloc] initWithNibName: nil bundle:nil]; 

不會太大的幫助,因爲你沒有提供一個筆尖名字(我想既然你沒有筆尖名字你不能用故事板用這個,但我不是100%確定)。

設置在Interface Builder您的viewController的標識符和實例化它是這樣的:

GenderViewController *myController = [self.storyboard instantiateViewControllerWithIdentifier: @"yourIdentifier"]; 
+0

Okey,我將Storyboard ID設置爲「GenderView」,並更新了代碼以使用instantiateViewControllerWithIdentifier。但我會得到錯誤:'2013-02-13 11:56:29.506 AppName [3676:c07] - [NSAutoresizingMaskLayoutConstraint isViewLoaded]:無法識別的選擇器發送到實例0x9344350 2013-02-13 11:56:29.507 AppName [3676: c07] ***終止應用程序由於未捕獲的異常'NSInvalidArgumentException',原因:' - [NSAutoresizingMaskLayoutConstraint isViewLoaded]:無法識別的選擇器發送到實例0x9344350'' – 2013-02-13 10:58:42

+0

好吧,我解決了這個問題。我刪除了釋放myController行,現在一切正常。謝謝! – 2013-02-13 14:03:20

0

其實你有GenderViewController筆尖文件。但是,當您分配類GenderViewController時,您通過傳遞nil來創建它。