简体   繁体   English

主UIViewController的子视图中可以有两个导航控制器吗?

[英]Can you have two Navigation Controllers in subviews of a Main UIViewController?

The following image explains what I'm trying to do: 下图说明了我要执行的操作:

http://img337.imageshack.us/img337/1475/multinav.png http://img337.imageshack.us/img337/1475/multinav.png

This is for an iPad app. 这是针对iPad应用的。 Is it possible? 可能吗? And if so, can someone post the skeleton code to do it? 如果是这样,有人可以发布框架代码来做到这一点吗?

Thanks in advance 提前致谢

Yes, it's possible. 是的,有可能。 Skeleton code: 骨架代码:

Header file: 头文件:

@interface SGBSplitViewController : UIViewController

@property (nonatomic, strong, readonly) UIViewController *leftViewController;
@property (nonatomic, strong, readonly) UIViewController *rightViewController;

- (id)initWithLeftViewController:(UIViewController *)leftViewController
             rightViewController:(UIViewController *)rightViewController;

@end

Implementation file: 实施文件:

@implementation SGBSplitViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    return nil;
}

- (id)initWithLeftViewController:(UIViewController *)leftViewController
             rightViewController:(UIViewController *)rightViewController
{
    self = [super initWithNibName:nil bundle:nil];
    if (self)
    {
        _leftViewController = leftViewController;
        _rightViewController = rightViewController;
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self addChildViewController:self.leftViewController];
    [self.view addSubview:self.leftViewController.view];
    [self.leftViewController didMoveToParentViewController:self];

    [self addChildViewController:self.rightViewController];
    [self.view addSubview:self.rightViewController.view];
    [self.rightViewController didMoveToParentViewController:self];
}

- (void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];

    self.leftViewController.view.frame = <frame>;
    self.rightViewController.view.frame = <frame>;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在不使用导航控制器堆栈,子视图或模态控制器的情况下更改视图控制器的动画? - Animate change of view controllers without using navigation controller stack, subviews or modal controllers? 具有3个UIViewController子视图的UIScrollView - UIScrollView with 3 UIViewController subviews 子视图从UIViewController中消失 - Subviews disappearing from UIViewController 如何使两个子视图相互交互? - How to have two subviews interact with each other? 在一个应用程序中使用两个导航控制器的问题 - Problem with using two navigation controllers in one application 在 UIViewController 中布局和调整子视图的大小 - Laying out & sizing of subviews in a UIViewController 你能在 UINavigation 堆栈上推送 2 个相同的 UIViewController 吗? - can you push 2 of the same UIViewController on the UINavigation stack? 在具有导航控制器的UIviewController中添加tabbarController的最佳方法? - Best Way to add a tabbarController in a UIviewController which have a navigation controller? 将UIViewController子视图重置回初始位置 - Resetting UIViewController subviews back to the initial positions UIViewController取消分配时不释放子视图(使用ARC) - UIViewController not releasing subviews when dealloc (using ARC)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM