【问题标题】:ios UINavigationController subview frame issueios UINavigationController 子视图框架问题
【发布时间】:2015-03-27 08:15:55
【问题描述】:

这是我在mainViewController.m中的代码:

#import "SideViewController.h"

- (void)viewDidLoad{
     SideViewController *sideVC = [[SideViewController alloc] initWithFrame:CGRectMake(0, 0, 250,self.view.bounds.size.height)];
    [self.navigationController.view addSubview:sideVC.view];          
}

mainViewController嵌入 UINavigationController 通过情节提要

sideViewController添加UINavigationController 作为它的子视图,因为我需要它覆盖Navigation Bar

以及它在 iOS8 模拟器上的显示方式:

我怎样才能使它适合屏幕边界?

【问题讨论】:

  • 你好,你能找到解决办法吗?

标签: ios objective-c uinavigationcontroller frame addsubview


【解决方案1】:

我猜 autoresize mask 解决了这个问题:

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

    if (self)
    {
        sideVC = [SideViewController new];
        [sideVC.view setFrame:CGRectMake(0, 0, 250,self.view.bounds.size.height)];
        sideVC.view.autoresizingMask = UIViewAutoresizingNone;
    }

    return self;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-26
    • 1970-01-01
    相关资源
    最近更新 更多