addChildViewController ipad 中Controller的嵌套和叠加

原文链接: http://www.cnblogs.com/james1207/p/3320043.html

1.addChildViewController 在 base controller中添加子的controller,会自动调用子的controller中viewDidload,viewWillAppear等视图方法,可以完成一个controller叠加各种视图

2.base 的controller必须是UIViewController,如果是 UINavigationController,则没法控制子controller frame的大小

示例代码:

    BaseNavController * nav = [[BaseNavController alloc] initWithRootViewController:agendaController];
    nav.view.autoresizingMask = UIViewAutoresizingNone;
    [nav.view addGestureRecognizer:[[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(dragView:)]];
    [self addChildViewController:nav];
    
    
    nav.view.frame =  CGRectMake(270, -20, DeviceWidth - 270, DeviceHeight - 200);//homeViewLeftMenuViewWidth
    
    nav.view.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:nav.view];


转载于:https://www.cnblogs.com/james1207/p/3320043.html

猜你喜欢

转载自blog.csdn.net/weixin_30662539/article/details/94985697
今日推荐