Iphone 从UINavigationController中推出UITABBARC控制器
我有一个UINavigationController,我正在成功地从一个视图导航到另一个视图。但在某个时候,我想展示一个带有一些视图的UITabBarController (我从列表中选择一个用户,并希望通过选项卡显示他的个人资料(包含多个视图) 我找了,试了试,什么都没有。。。 我找不到这样的人Iphone 从UINavigationController中推出UITABBARC控制器,iphone,ios,xcode,Iphone,Ios,Xcode,我有一个UINavigationController,我正在成功地从一个视图导航到另一个视图。但在某个时候,我想展示一个带有一些视图的UITabBarController (我从列表中选择一个用户,并希望通过选项卡显示他的个人资料(包含多个视图) 我找了,试了试,什么都没有。。。 我找不到这样的人 有谁能给我一些建议,告诉我如何为UIAbbarController创建nib文件,以及如何从导航控制器中推送它吗?当然,为什么不将新UIViewController的数组重新分配给UIAbbarCon
有谁能给我一些建议,告诉我如何为UIAbbarController创建nib文件,以及如何从导航控制器中推送它吗?当然,为什么不将新UIViewController的数组重新分配给UIAbbarController的viewControllers属性?那就行了
- (void)addNewControllers {
NSMutableArray *controllers = [NSMutableArray array];
UIViewController *c0 = [[[UIViewController alloc] init] autorelease];
[controllers addObject: c0];
UIViewController *c1 = [[[UIViewController alloc] init] autorelease];
[controllers addObject: c1];
UIViewController *c2 = [[[UIViewController alloc] init] autorelease];
[controllers addObject: c2];
[myTabBarController setViewControllers:controllers];
}
调用上述函数
然后[self.navcont pushviewcontroller:mytabbarcontroller动画:是]
通过使用IB替换nibname函数,将这些uiviewcontroller更改为您自己的
更多
当然,为什么不将新UIViewController的数组重新分配给UIAbbarController的ViewController属性?那就行了
- (void)addNewControllers {
NSMutableArray *controllers = [NSMutableArray array];
UIViewController *c0 = [[[UIViewController alloc] init] autorelease];
[controllers addObject: c0];
UIViewController *c1 = [[[UIViewController alloc] init] autorelease];
[controllers addObject: c1];
UIViewController *c2 = [[[UIViewController alloc] init] autorelease];
[controllers addObject: c2];
[myTabBarController setViewControllers:controllers];
}
调用上述函数
然后[self.navcont pushviewcontroller:mytabbarcontroller动画:是]
通过使用IB替换nibname函数,将这些uiviewcontroller更改为您自己的
更多
不要那样做。将tabbatcontroller添加到您的mainwindow类。无论何时,只要您需要应用程序中的tabar。只需卸下UINavigationController并添加UITabBarController
AppDelegate *delegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
delegate.tCtr.selectedIndex = index;
delegate.tCtr.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:delegate.tCtr animated:YES];
MainScreen *mainScreen = [[MainScreen alloc] initWithNibName:@"MainScreen" bundle:nil];
mainScreen.navigationItem.hidesBackButton = YES;
self.navigationController.navigationBar.hidden = YES;
[self.navigationController pushViewController:mainScreen animated:YES];
或
将tabbatcontroller添加到您的主窗口类和
仅显示当前viewcontroller中的控制器
AppDelegate *delegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
delegate.tCtr.selectedIndex = index;
delegate.tCtr.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:delegate.tCtr animated:YES];
MainScreen *mainScreen = [[MainScreen alloc] initWithNibName:@"MainScreen" bundle:nil];
mainScreen.navigationItem.hidesBackButton = YES;
self.navigationController.navigationBar.hidden = YES;
[self.navigationController pushViewController:mainScreen animated:YES];
不要那样做。将tabbatcontroller添加到您的mainwindow类。无论何时,只要您需要应用程序中的tabar。只需卸下UINavigationController并添加UITabBarController
AppDelegate *delegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
delegate.tCtr.selectedIndex = index;
delegate.tCtr.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:delegate.tCtr animated:YES];
MainScreen *mainScreen = [[MainScreen alloc] initWithNibName:@"MainScreen" bundle:nil];
mainScreen.navigationItem.hidesBackButton = YES;
self.navigationController.navigationBar.hidden = YES;
[self.navigationController pushViewController:mainScreen animated:YES];
或
将tabbatcontroller添加到您的主窗口类和
仅显示当前viewcontroller中的控制器
AppDelegate *delegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
delegate.tCtr.selectedIndex = index;
delegate.tCtr.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:delegate.tCtr animated:YES];
MainScreen *mainScreen = [[MainScreen alloc] initWithNibName:@"MainScreen" bundle:nil];
mainScreen.navigationItem.hidesBackButton = YES;
self.navigationController.navigationBar.hidden = YES;
[self.navigationController pushViewController:mainScreen animated:YES];
这是一项简单的任务,制作了一个UIViewController,并在其中添加为子视图UIAbbarController。现在,您可以使用navigationcontroller将其推送到该控制器
AppDelegate *delegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
delegate.tCtr.selectedIndex = index;
delegate.tCtr.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:delegate.tCtr animated:YES];
MainScreen *mainScreen = [[MainScreen alloc] initWithNibName:@"MainScreen" bundle:nil];
mainScreen.navigationItem.hidesBackButton = YES;
self.navigationController.navigationBar.hidden = YES;
[self.navigationController pushViewController:mainScreen animated:YES];
在主屏幕控制器的viewDidLoad方法中,将TabBarController添加为self.view中的子视图。还制作了tabbarcontroller的出口,并将其与interface builder tabbarcontroller对象连接。制作UIViewController并在其中添加为子视图UIAbarController是一项简单的任务。现在,您可以使用navigationcontroller将其推送到该控制器
AppDelegate *delegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
delegate.tCtr.selectedIndex = index;
delegate.tCtr.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:delegate.tCtr animated:YES];
MainScreen *mainScreen = [[MainScreen alloc] initWithNibName:@"MainScreen" bundle:nil];
mainScreen.navigationItem.hidesBackButton = YES;
self.navigationController.navigationBar.hidden = YES;
[self.navigationController pushViewController:mainScreen animated:YES];
在主屏幕控制器的viewDidLoad方法中,将TabBarController添加为self.view中的子视图。还制作了tabbarcontroller的出口,并将其与interface builder tabbarcontroller对象连接。既然@Rakesh Bhatt的答案对我有效,下面是使其运行的等效Monotouch代码。我的情况是,我有一个SignInViewController,我首先展示,然后用UITabBarController子类替换它
AppDelegate.Navigation.SelectedIndex = 0;
AppDelegate.Navigation.ModalTransitionStyle = UIModalTransitionStyle.FlipHorizontal;
PresentViewController (AppDelegate.Navigation, true, null);
既然@Rakesh Bhatt的答案对我有效,下面是让它运行的等效Monotouch代码。我的情况是,我有一个SignInViewController,我首先展示,然后用UITabBarController子类替换它
AppDelegate.Navigation.SelectedIndex = 0;
AppDelegate.Navigation.ModalTransitionStyle = UIModalTransitionStyle.FlipHorizontal;
PresentViewController (AppDelegate.Navigation, true, null);
试试我的答案,它测试了一个。试试我的答案,它测试了一个。我使用了[self.navigationController-pushViewController:tabBarController-animated:YES];不能将选项卡栏控制器添加为我使用的子视图[self.navigationController pushViewController:tabBarController animated:YES];无法添加选项卡栏控制器,因为子视图的工作方式与champ类似!发布monotouch代码,作为一个单独的答案帮助人们解决问题。工作起来就像一个冠军!发布monotouch代码,作为单独的答案帮助人们解决问题。