![](/img/trans.png)
[英]Add a subview to a UIImageView that is the view outlet of a UIViewController in IB
[英]Add UIViewControllers View as a subView of another UIViewController view
我有一个称为TestView的UiView,它已作为NumberViewController的子视图添加。
在我的应用程序启动时,我的rootViewController是PaperViewController,它具有我通过xib添加的一些UIButton,现在我想将NumberViewController的视图添加为PaperViewController的子视图,所以我做到了
NumberViewController = [[NumberViewController alloc] initWithNibName:@"NumberViewController" bundle:nil];
NumberViewController.delegate = self;
[self.view addSubview:NumberViewController.view];
NumberViewController.view.backgroundColor = [UIColor clearColor];
NumberViewController.view.hidden = YES;
现在将其隐藏,因为我将在单击某个按钮时取消隐藏它,然后将显示NumberViewContrller的视图。
但是,假设我通过代码在PaperViewController中添加了一些按钮,然后取消隐藏NumberViewController的视图,则两个视图重叠。
我不明白问题出在哪里,我犯了什么错误。 朋友们请帮帮我
问候兰吉特。
在标题中添加UIView:
@property (weak, nonatomic) IBOutlet UIView *addChildView;
在- (void)viewDidLoad
方法中执行以下操作:
ChildViewController *nonSystemsController = [[ChildViewController alloc] initWithNibName:@"ChildViewController" bundle:nil];
nonSystemsController.view.frame = self.addChildView.bounds;
[self.addChildView addSubview:nonSystemsController.view];
[nonSystemsController didMoveToParentViewController:self];
[self addChildViewController:nonSystemsController];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.