ios UINavigationController子视图框架问题

时间:2015-03-27 08:15:55

标签: ios objective-c uinavigationcontroller frame addsubview

这是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 已添加至<{1}}作为子视图,因为我需要它涵盖UINavigationController

以及它在iOS8模拟器上的显示方式: enter image description here

我怎样才能让它适合屏幕界限?

1 个答案:

答案 0 :(得分:0)

我猜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;
}