在tabbar控制器中打开子视图

时间:2014-04-08 07:52:20

标签: objective-c ios7

我正在使用故事板和xib这两个& ios7.In bellow screenshot我在故事板中使用了标签栏控制器,但是当我试图打开下一个视图控制器(xib)时,单击它没有在同一视图中打开。我想在同一个视图上打开该视图或tab.I尝试了太多方法但没有工作。请帮我解决这个问题。

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath 
   *)indexPath
{  
   FriendProfileViewController *FPVController = [[FriendProfileViewController  
   alloc]initWithNibName:@"FriendProfileViewController" bundle:nil];
   // [self presentViewController:FPVController animated:YES completion:nil];
  [self.navigationController pushViewController:FPVController animated:YES];
}

enter image description here enter image description here

1 个答案:

答案 0 :(得分:1)

您想要使用UINavigationController:

[self.navigationController pushViewController:FPVController animated:YES];

您是否也在故事板中提供了一个?如果没有UINavigationController,这不能推新的:-) 你的故事板可能看起来像: enter image description here

要完成此操作,请执行以下操作: 将UINavigationController拖放到故事板中。 右键单击并从TabBarController拖动到新的UINavigationcontroller上,然后选择" viewControllers"。 现在右键单击并从新的UINavigationcontroller拖动到UITableViewController并选择" root"。之后删除从UITableViewController到UITableViewController的连接,因为这不会直接作为tabbar的viewcontroller,而是通过UINavigationController间接的: - )