你可以添加一個tabBarController到你的SplitViewController的詳細視圖。只需創建一個響應<UITabBarControllerDelegate>
的UIViewController
,並在該控制器的xib文件中添加一個UITabBarController
對象並將其鏈接到您的UIViewController。在你viewDidLoad
標籤欄控制器添加到視圖:
-(void)viewDidLoad {
...
[self addChildViewController:myTabBarController];
//add the tabBarController view
[self.view addSubview:myTabBarController.view];
}
這UIViewController
將分配給您的詳細信息視圖。這工作,我已經嘗試過。但是,蘋果是否會允許它?我不知道!
編輯:
首先你不應該叫viewDidLoad
自己。
此外,我不認爲你需要rootipad
和detailipad
只要控制器鏈接到xib文件中的SplitViewController。
在
RootViewiPad
(主)
添加其viewDidLoad
內的以下內容:
-(void)viewDidLoad {
...
if (self.interfaceOrientation == UIInterfaceOrientationPortrait || self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
//select the first row to load
[self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionNone];
//NOTE, I'm assuming that selecting the cell will load the detail view.
//if that is not the case, you need to do what ever you need to load the
//detail view.
}
}
如果你想這種行爲發生的每一次(不只是第一次加載),那麼代碼添加到
-(void)viewWillAppear
方法,而不是
。
不知道我是否想嘗試一些可能最終被Apple拒絕的東西。也許更好的選擇是以某種方式獲取詳細信息視圖(以縱向模式顯示整個屏幕的視圖),以便在啓動時獲取最新文章,並在啓動時顯示而不是空白?但是,不知道該怎麼去做。 – user717452
即時通訊不知道這是否會被蘋果拒絕..如果他們的準則沒有嚴格提及,你不能在一個splitView中有一個tabBarController然後上述將罰款..對於你的其他解決方案它安靜簡單..因爲主view controller是一個tableViewController,檢查'viewDidLoad'的方向,然後只需要'selectRowAtIndexPath:animated:scrollOption:'選擇第一個加載詳細視圖的選項。 – KDaker
我不確定你在這裏所做的是什麼,但這裏是我的嘗試。在AppDelegate didFinishLaunching上,我將主控制器(表視圖)設置爲控制器,並告訴它在主控制器代碼中運行一個方法。然後通知該方法從索引0處的數組中選擇條目。問題是由於某種原因,解析不會發生,所以數組不會被創建,它崩潰的索引0錯誤超出了空數組的限制 – user717452