2010-01-17 162 views
0

嗨,我需要一些幫助,這:iPhone:視圖控制器的標籤欄

我有兩個視圖控制器,讓我們說:

  • FirstViewController(第一)是navigationviewcontroller
  • SecondViewController內(二)

所以在第一的viewDidLoad方法,我有這樣的:

SecondViewController *second = [[SecondViewController alloc] initWithNibName:...]; 

[self.addsubview:second.view]; 

我已經完成了這個cuz我想用我的自定義按鈕和顏色製作自定義標籤欄。

我有這樣當我按下自定義「標籤欄」(seconviewcontroller)

ConfiguracionViewController *conf = [[ConfiguracionViewController alloc] initWithNibName:@"ConfiguracionView" bundle:nil]; 

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

的按鈕中的一個,但由於第二視圖控制器沒有被按下,或在第一視圖控制器I可以模態呈現無法訪問navigationController。我也試過這個

[self.parentViewController.navigationController pushViewController:...]; 

但它也沒有工作。

請幫助我,我需要學習如何做到這一點,併爲我的壞英語感到抱歉。

最好的問候,
卡洛斯巴爾

回答

1

首先,你不應該被加入到這樣的第一視圖第二種觀點:

[self.view addSubview:second.view]; 

酒店parentViewController不會在這種情況下,由於工作其次不是導航層次結構的一部分。

相反,你可以讓你自己的財產引用「父」視圖控制器:

SecondViewController *second = [[SecondViewController alloc] initWithNibName:...]; 

// set new property 
second.parentVC = self; 

[self.view addSubview:second.view]; 

在SecondViewController.h你需要申報「parentVC」和SecondViewController.m實例變量和財產你需要綜合這個屬性。

然後,你應該能夠從SecondViewController.m訪問導航控制器和推視圖控制器是這樣的:

[self.parentVC.navigationController pushViewController:...]; 
+0

由於它的工作! – 2010-01-18 05:28:04

相關問題