iOS使用自定义容器视图控制器

时间:2014-02-05 22:15:01

标签: ios containers addsubview

我尝试使用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];
}
应显示

:显示____________________________________:

enter image description here ___________ enter image description here

0 个答案:

没有答案