我正在使用存储在核心数据中的 Person 对象填充 UITableView。每个人都有名字、姓氏和图像。图像是与单独的图像实体的关系,该实体具有称为可转换类型数据的属性。这是我存储与每个人相关的图像的地方。
我正在用以下内容填充表格:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"PersonCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
Person *person = [self.fetchedResultsController objectAtIndexPath:indexPath];
NSMutableString *nameString = [[NSMutableString alloc] init];
if (person.firstName)
{
[nameString appendString:[NSString stringWithFormat:@"%@ ",person.firstName]];
}
if (person.lastName)
{
[nameString appendString:person.lastName];
}
cell.textLabel.text = nameString;
UIImage *image = person.image.data;
cell.imageView.image = image;
return cell;
}
当我运行我的应用程序时,出现错误:
: CGAffineTransformInvert: 奇异矩阵。
表或数据库中的每个项目一次。
如果我注释掉这一行:
cell.imageView.image = image;
错误消失了。
有什么想法吗?这是我第一次在 Core Data 中存储二进制数据,也许它没有转换吧?
这就是我存储图像的方式:
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
self.person = [Person personWithImage:image inManagedObjectContext:self.context];
和
+ (Person *)personWithImage: (UIImage *)image inManagedObjectContext:(NSManagedObjectContext *)context
{
Image *newImage = [NSEntityDescription insertNewObjectForEntityForName:@"Image" inManagedObjectContext:context];
newImage.data = image;
Person *newPerson = [NSEntityDescription insertNewObjectForEntityForName:@"Person"
inManagedObjectContext:context];
newPerson.image = newImage;
return newPerson;
}
谢谢,
格里
最佳答案
好吧,我很幸运地解决了这个问题。我的 uitableview 使用单元格中的图像,我将全尺寸相机图像放在那里,当然遇到了一些内存问题。一旦我开始将图像调整为 960x640,随机的 CGAffineTransformInvert 错误就消失了!
我仍然不知道它为什么会发生,但我想这并不重要,因为它现在已经消失了。
关于iphone - 在 UITableViewCell 中设置图像时,出现 <Error> : CGAffineTransformInvert: singular matrix,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11455214/