2011-02-11 77 views
0

我有一個非常簡單的問題。我有一個視圖控制器。在視圖控制器中,我添加了幾個按鈕。點擊按鈕時,我必須啓動一個標籤欄控制器(其中每個都有導航控制器)。Iphone:無法從導航欄控制器返回

代碼段:

- (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和導航控制器。問題是一旦按鈕被點擊,我無法回到主視圖。

任何人都可以指導我如何回到以前的視圖,以便我可以點擊其他按鈕。

回答

1

在這種情況下,我會考慮以模態方式呈現標籤欄控制器。這是組織用戶界面的相同方式組織視圖的一種更簡潔的方式。您可以關閉模​​式演示文稿以返回到上一個視圖。有關類似的建議和示例,請閱讀適用於iOS的View Controller編程指南。

+0

感謝您的回答。我通讀了指南並現在實施了應用程序和導航工作。 – Pintu 2011-02-18 00:37:13

0

不知道如果我得到你正在嘗試做的,但如果你想在標籤欄控制器,以便再次消失,唯一的辦法將是

[self.view addSubview:tabBarController.view]; 

逆可能是

[tabBarController.view removeFromSuperview]; 

我必須說它看起來像一個奇怪的建築,但它可能會工作。