我的应用程序有很多事情要做,哈哈。在我的主菜单上,如果您单击“聊天”,它将带您进入聊天 XIB。
如果您查看导航栏的左上角,我有一个叫做“主菜单”的东西。我希望这能带我回到主菜单。我的主菜单位于 main.Storyboard 上。 Chat 是一个 XIB。两个 View 都有选项卡栏。我整天都在兜圈子试图弄清楚这一点。这是我最后一次尝试崩溃的事情:
-(void)MainMenu
{
MainMenuTabBarControllerViewController *MMTBC = [[MainMenuTabBarControllerViewController alloc]init];
[self.navigationController popToViewController:MMTBC animated:YES];
}
- (void)viewDidLoad
//-------------------------------------------------------------------------------------------------------------------------------------------------
{
[super viewDidLoad];
self.title = @"Group";
//---------------------------------------------------------------------------------------------------------------------------------------------
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"New" style:UIBarButtonItemStylePlain target:self
action:@selector(actionNew)];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Main Menu" style:UIBarButtonItemStyleBordered target:self action:@selector(MainMenu)];
//---------------------------------------------------------------------------------------------------------------------------------------------
self.tableView.tableFooterView = [[UIView alloc] init];
//---------------------------------------------------------------------------------------------------------------------------------------------
chatrooms = [[NSMutableArray alloc] init];
}
最佳答案
因为您的应用程序中有两个标签栏 Controller 。我认为使用导航 Controller (推送/弹出)来管理它们之间的转换不是一个好主意。试试 presentViewController .
按下聊天按钮时,显示第二个选项卡 View Controller 。
- (IBAction)chatButtonPressed:(id)sender {
ChatTabBarController *chatTabView = ... // allocate memory and initialize
[self presentViewController:chatTabView animated:YES completion:nil];
}
按下主菜单按钮时,将其关闭。
- (IBAction)mainMenuButtonPressed:(id)sender {
[self dismissViewControllerAnimated:YES completion:nil];
}
编辑:
请注意几年前有人问过一个非常相似的问题。看看这个:
How can I push tab bar controller after click a button from a view in objective c?
关于ios - XIB 中的导航栏项目,呈现 Storyboard选项卡栏 Root View Controller Segue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28139754/