[英]Iphone: Unable to return back from navigation bar controller
我有一個非常簡單的問題。 我有一個視圖控制器。 在視圖控制器中,我添加了一些按鈕。 在按鈕上單擊,我必須啟動一個選項卡欄控制器(每個都有導航控制器)。
代碼段:
- (IBAction) pushNewsAlertsController:(id)sender {
//Create a navigation controller
UINavigationController *FirstNavController = [[UINavigationController alloc] init] ;
//create the view controller (table view controller)
FirstViewController *firstViewController = [[FirstViewController alloc] init];
[FirstNavController pushViewController:firstViewController animated:YES];
//Create a navigation controller
UINavigationController *secondNavController = [[UINavigationController alloc] init] ;
//create the view controller (table view controller)
SecondViewController *secondViewController = [[SecondViewController alloc] init];
[secondNavController pushViewController:secondViewController animated:YES];
// Set the array of view controllers
tabBarController.viewControllers = [NSArray arrayWithObjects:firstNavController, secondNavController, nil] ;
//Add the tab bar controller's view to the window
[self.view addSubview:tabBarController.view];
}
我能夠添加tabviews和導航控制器。 問題是單擊按鈕后,我無法回到主視圖。
誰能指導我如何返回上一個視圖,以便我可以單擊其他按鈕。
在這種情況下,我將考慮以模式方式顯示標簽欄控制器。 這是一種與組織用戶界面相同的更干凈的方式來組織視圖。 您只需關閉模式演示文稿即可返回上一個視圖。 閱讀iOS版《 View Controller編程指南》,以獲取類似的建議和示例。
不知道我是否知道您要嘗試執行的操作,但是如果您希望標簽欄控制器視圖再次消失,唯一的方法是
[self.view addSubview:tabBarController.view];
可能是
[tabBarController.view removeFromSuperview];
我必須說,這看起來像是您正在構建的奇怪結構,但是它仍然可以工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.