ios - UINavigationController 框架问题

标签 ios uinavigationcontroller

我的 View Controller A 中有 UINavigationController

@property (nonatomic, strong) UINavigationController *containerNavigationController;

在 View Controller A 中我有初始化方法

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];

    if (self)
    {
        _containerNavigationController = [UINavigationController new];

       _containerNavigationController.navigationBarHidden = YES;
    }

    return self;
}

在查看加载方法时我有这段代码:

[self.view addSubview:_containerNavigationController.view];

[_containerNavigationController.view setFrame:CGRectMake(247, 64, 700, 700)];

如您所见,nag view os 的高度为 700,但是当我运行应用程序时,我可以看到大约 400 pt 的 nag view 高度。但是,如果我将高度设置为 10000,则会显示所有 View 。所以我有另一个 Controller ,它是 _containerNavigationController 的 Root View Controller ,这就是为什么我可以检查 Root View Controller 的某些 View 是否隐藏的原因。所以当高度为 700 时,我只能看到 Root View 的一半,但是当高度为 10000 时,我可以看到整个 View

当我按下 View Controller A 中的某个按钮时我设置了 root

vc = (UIViewController *)[sb instantiateViewControllerWithIdentifier:@"STScheduelPlayersViewController"];

[_containerNavigationController setViewControllers:@[vc] animated:YES];

这是在设置 rect 时加载的登录 View

(lldb) po _containerNavigationController.view
<UILayoutContainerView: 0x8b3afd0; frame = (247 64; 778 777); autoresize = W+H; gestureRecognizers = <NSArray: 0x8b39350>; layer = <CALayer: 0x8b3b460>>

点击按钮时的日志

(lldb) po _containerNavigationController.view
<UILayoutContainerView: 0x8b3afd0; frame = (247 64; 1034 521); autoresize = W+H; gestureRecognizers = <NSArray: 0x8b39350>; layer = <CALayer: 0x8b3b460>>

最佳答案

想知道但是 autoresize mask 解决了这个问题:

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];

    if (self)
    {
        _containerNavigationController = [UINavigationController new];
        [_containerNavigationController.view setFrame:CGRectMake(247, 64, 778, 777)];
        _containerNavigationController.view.autoresizingMask = UIViewAutoresizingNone;
        _containerNavigationController.navigationBarHidden = YES;
    }

    return self;
}

关于ios - UINavigationController 框架问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22364450/

相关文章:

ios - 在 Firebase 中查询嵌套元素

ios - UINavigationController 子类并推送 Segues

uinavigationcontroller - 自定义 UIBarButtonItem 与 iOS7 对齐

导航 Controller 转换上的 iOS 黑线

ios - 带有 sendAsynchronousRequest Objective-C 的 NSURLConnection 进度条

iOS App - 在用户选择的浏览器中打开网站

ios - 具有自动调整单元格 (estimatedSize) 和 sectionHeadersPinToVisibleBounds 的 UICollectionView 变得精神起来

objective-c - 我应该如何或在何处存储我在 iOS 应用程序中全局需要的对象实例?

swift - 以编程方式更改 View

objective-c - 在这种情况下如何实现 UINavigationController?