【发布时间】:2016-01-03 01:41:56
【问题描述】:
我正在尝试使用以下代码将代码中的子视图控制器添加到情节提要中的当前视图控制器:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
LogInTutorialViewController *lvc = [[LogInTutorialViewController alloc] init];
lvc = (LogInTutorialViewController *)[storyboard instantiateViewControllerWithIdentifier:@"LogInTutorialViewControllerID"];
[self displayContentController:lvc];
- (void) displayContentController: (LogInTutorialViewController*) content;
{
//add as childViewController
[self addChildViewController:content];
[content didMoveToParentViewController:self];
[content.view setFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
[self.view addSubview:content.view];
}
视图似乎至少在模拟器上显示,但在控制台中我得到很多或错误:
<Error>: CGContextSaveGState: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
还有相同的描述但不同的错误:
CGContextSetLineWidth、CGContextSetLineJoin、CGContextSetLineCap、CGContextSetMiterLimit、CGContextSetFlatness、CGContextAddPath、CGContextDrawPath、CGContextRestoreGState
所有这些错误都会被记录两次。
有谁知道我做错了什么?
我还阅读了一些帖子,其中一些建议在传递数据之前分配和初始化视图控制器,我也尝试过,但没有任何运气。
【问题讨论】:
-
你不需要这条线
LogInTutorialViewController *lvc = [[LogInTutorialViewController alloc] init];,因为你是从故事板实例化的。对于下面的错误检查答案,我相信您的订单不正确。 -
是的,我知道,但我只是按照建议的帖子尝试过
标签: ios objective-c uinavigationcontroller