我尝试使用UIViewController
作为自定义ContainerViewController来显示具有自定义行为的某些ViewControllers。我在ContainerViewController中有一个UIView
“detailsView”属性来显示加载的ViewControllers的内容。问题是显示加载的控制器但没有任何内容,如按钮。我做错了什么?
我的ContainerViewContoller.h的一部分:
@property (weak, nonatomic) IBOutlet UIView *detailsView;
@property (strong, nonatomic) UIViewController *currentViewController;
我的ContainerViewContoller.m的viewDidLoad
方法:
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"called");
SWResultViewController *swResultViewController = [[SWResultViewController alloc]init];
self.currentViewController = swResultViewController;
// this line doesn't help to show the buttons
swResultViewController.view.frame = self.detailsView.bounds;
[self addChildViewController: self.currentViewController];
[self.detailsView addSubview: self.currentViewController.view];
[self.currentViewController didMoveToParentViewController:self];
}
应显示:显示____________________________________:
___________