我一直在研究這個問題一段時間,並認爲我會尋求一些幫助。我有3個視圖控制器:1個導航控制器,1個主控制器和1個詳細視圖控制器。從子視圖導航視圖控制器
在主視圖控制器中,我有一系列按鈕的子視圖。但是,由於類結構,我無法直接調用self.storyboard來獲取當前故事板對象。
我已經嘗試了2種不同的方法,各種方式,但仍然不成功。我在下面發佈了我的方法,並描述了每個細分市場中沒有發生的事情和情況。總體目標是通過點擊子視圖中的按鈕來呈現子視圖控制器(詳細視圖),該子視圖中無法直接訪問父級故事板。
方法1
//Instantiate the new view controller
ProfileViewViewController *tempViewToShow = [del.window.rootViewController.storyboard instantiateViewControllerWithIdentifier:@"profile"];
// Pass data into the new view controller
tempViewToShow.thisUser = self.postUser;
// Output a simple log to ensure both were created
NSLog(@"Temp User Name: %@, Profile Desc: %@", [tempViewToShow.thisUser getFullName], tempViewToShow.description);
// Using the AppDelegate for the RootViewController, present the detail view
[UIApplication.sharedApplication.delegate.window.rootViewController presentViewController:tempViewToShow animated:YES completion:NULL];
問題 這一系列的問題是,詳細視圖不攜帶導航控制器(因爲它未提及),然而,這種方式仍然顯示完整的視圖控制器
方法2
個...
// Use the Delegate and the navigation controller to present the new view controller
[UIApplication.sharedApplication.delegate.window.rootViewController.navigationController presentViewController:tempViewToShow animated:YES completion:NULL];
問題 不顯示任何內容
方法3
// Use the recommended 'pushViewController' for the navigation controller to carry over
[UIApplication.sharedApplication.delegate.window.rootViewController.navigationController pushViewController:tempViewToShow animated:NO];
問題 不顯示任何內容
恩託託,我會如何做這項工作?我會修改哪些行,以及如何修改?謝謝!
你想要做什麼?你想要導航欄嗎? – KKRocks