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

发布于 2024-09-08 06:15:27 字数 246 浏览 1 评论 0原文

下图解释了我正在尝试执行的操作:

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

这是针对 iPad 应用程序的。是否可以?如果是这样,有人可以发布框架代码来做到这一点吗?

提前致谢

The following image explains what I'm trying to do:

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

This is for an iPad app. Is it possible? And if so, can someone post the skeleton code to do it?

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光瘦了 2024-09-15 06:15:27

是的,这是可能的。框架代码:

头文件:

@interface SGBSplitViewController : UIViewController

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

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

@end

实现文件:

@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>;
}

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>;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文