2013-08-16 77 views
1

我正在使用故事板和卡爾日曆控制器,我想定製在日曆上選擇一天的事件。默認情況下,當您選擇一天時,當天的事件顯示在月份日曆下的表格視圖中。我想要做的是在選擇某一天時另一個視圖控制器顯示出來,並在選定的一天進行過濾。定製Kal日曆事件

直到現在我建立了我應該編輯的地方。但我不能打電話給別人看!

我試過了,但它不起作用!

tableViewController *tbl = [[tableViewController alloc] initWithNibName:@"menuView" bundle:nil]; 

    [self dismissViewControllerAnimated:YES completion:nil]; 

我發現這個,但我不知道如何使用它,如果它對我有幫助或沒有..任何幫助嗎?

UIStoryboard* sb = [UIStoryboard storyboardWithName:@"menuView" bundle:nil]; 
tableViewController *vc = [sb instantiateViewControllerWithIdentifier:@"menuView"]; 

回答

1

第二批代碼在你的問題是正確的方向,但不完全正確。

首先,您想獲取項目故事板的實例。這就是你在第一行代碼中試圖做的。不過,我相信你是用錯誤的名字來提到你的故事板。通常,Xcode將故事板的名稱默認爲「MainStoryboard.storyboard」,而您試圖將其稱爲「menuView」。所以你需要將第一行代碼更改爲:

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; 

接下來,您需要一種方法來引用Storyboard中所需的ViewController。這就是你在第二行代碼中嘗試的內容。你需要確保你得到一個適當的參考吧:

  1. 在你的故事板,選擇你想顯示
  2. 在身份檢查器中的視圖控制器,在輸入類「tableViewController」現場
  3. 在故事板ID字段中輸入「menuView」

最後,你需要添加的代碼,以實際存在的視圖控制器一行。

因此,所有的所有的代碼應該是這個樣子:

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; 
tableViewController *vc = [sb instantiateViewControllerWithIdentifier:@"menuView"]; 

[self presentViewController:vc animated:YES completion:nil]; 
+0

我能問一個問題嗎? – etab

+1

您應該發佈一個新問題。 – hgwhittle