self.loginView = [self.storyboard instantiateViewControllerWithIdentifier:@"LOGIN"];
[self.view addSubview:self.loginView.view];
这段代码在iOS8上运行良好,但在iOS7上却无法正常工作,它只显示一半的屏幕,一半显示登录.
对此有什么解决方案?
self.loginView = [self.storyboard instantiateViewControllerWithIdentifier:@"LOGIN"];
[self addChildViewController:self.loginView];
[self.loginView.view setFrame:CGRectMake(0.0f, 0.0f, self.contentView.frame.size.width, self.contentView.frame.size.height)];
[self.contentView addSubview:self.loginView.view];
[self.loginView didMoveToParentViewController:self];
如果您不添加最后一行,则子视图控制器将不会接收事件.通过使用此代码,您可以同时在父视图控制器和子视图控制器中接收事件.