1

我正在製作一個顯示UILocalNotification的應用程序,當用戶點擊通知時,應用程序將顯示一個新的ViewController(在Storyboard中設計)從我的應用程序的任何地方storyboard instantiateViewControllerWithIdentifier:@「myIdentifier」顯示空白視圖控制器

要檢測用戶是否點擊了通知我做在didReceiveLocalNotification如下:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; 
UIViewController *checkListVC = [storyboard instantiateViewControllerWithIdentifier:@"MyCheckListVC"]; 
self.window.rootViewController = checkListVC; 

所以,當用戶點擊該通知,上面的代碼initiatizes我的視圖控制器(讓我們稱之爲它CheckListVC ),其標識符爲「MyCheckListVC」。 此CheckListVC具有tableView,其視圖控制器初始化時會調用其委託和數據源方法(numberOfRowsInSection & cellForRowAtIndexPath)。但問題是,當CheckListVC被初始化而不是顯示tableView時,模擬器顯示空白屏幕。

我無法調試它,因爲我甚至不知道問題出在哪裏。視圖控制器被正確初始化並且所有的委託/數據源方法得到正確調用,但屏幕變爲空白。

+0

你叫'[self.window makeKeyAndVisible]'後你SE你的rootViewController,這可能是問題。 – limon

+0

是的,我確實調用過'[self.window makeKeyAndVisible]',但它也沒有幫助。 – nefarianblack

回答

0

我想你忘記了標識符分配給UIStoryboard .. 1.select在「MyCheckListVC」的身份檢查故事情節 2.assign標識符名稱..

檢查這個圖像清晰度..

enter image description hereenter image description here

請按照下列步驟,並嘗試..我認爲這會工作.. :)

相關問題