简体   繁体   English

iOS8:无法在iOS8中添加/显示子视图控制器视图

[英]iOS8: Cannot able to add/show child view controllers view in iOS8

I have a strange problem particularly in iOS8. 我有一个奇怪的问题,尤其是在iOS8中。 I have a view controllers which shows content that came from other view controllers. 我有一个视图控制器,它显示来自其他视图控制器的内容。 This is what I am currently doing: 这是我目前正在做的:

     ViewController *childViewController = [[ViewController alloc] initWithNibName:@"PatientDetailsView" bundle:nil];
    [childViewController setPatient:patient];

   [self.view addSubview:patientDetailsViewController.view];

This above line of code runs fine on devices prior to iOS8 but on iOS8 application got stuck on addSubView method and no exception has been thrown by the compiler. 上面的这段代码在iOS8之前的设备上运行良好,但在iOS8应用程序上被困在addSubView方法上,并且编译器未引发任何异常。

I am not using storyboard in my project so cannot use container view controller to add a child view controller. 我没有在项目中使用情节提要,因此无法使用容器视图控制器添加子视图控制器。

try this code 试试这个代码

ViewController *childViewController = [[ViewController alloc] initWithNibName:@"PatientDetailsView" bundle:nil]; [self addChildViewController:childViewController]; [self.view addSubview:childViewController.view]; [childViewController didMoveToParentViewController:self];

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM