亲爱的开发者我想从离屏视图中创建图像。从屏幕视图中查看UIImage
当我启动我的应用程序的第一个视图是RootViewController和everthing 工作正常。
当我去其他视图,并做到这一点。
RootViewController *root = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
UIImage *screenShot = [self imageWithView: root.tableView];
(UIImage *) imageWithView:(UIView *)view
{
UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, [[UIScreen mainScreen] scale]);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
在该应用程序崩溃 “imageWithView:(UIView的*)视图” 在线 函数[view.layer renderInContext:UIGraphicsGetCurrentContext()];
日志说 终止应用程序由于未捕获的异常“NSInternalInconsistencyException”,原因是:“+ entityForName:未能找到NSManagedObjectModel的实体名称“列表项”
,这发生在RootViewController的上线
NSEntityDescription *entity = [NSEntityDescription entityForName:@"ListItem" inManagedObjectContext:self.managedObjectContext];
有人有想法吗?
我不会对你的代码发表评论,但该错误信息意味着您要么错读coredata实体的名称,要么您没有将您的App委托的managedObjectContext传递给您的视图控制器。换句话说,这与你的'UIImage from offscreen view'问题无关。 – Rog 2011-03-12 08:50:10
thx为答案...我认为它的第二点...如何以及在哪里将managedObjectContext传递给其他视图? – Missaq 2011-03-12 08:57:34