【发布时间】:2014-01-21 16:22:08
【问题描述】:
我正在创建一个学生索引应用程序,您可以在其中保存学生的姓名、图片和角色。一切正常,但是当我在应用程序测试时创建了一定数量的学生(带图片)时,应用程序运行速度非常慢。请查找随附的相应方法。有什么办法可以压缩图像数据的大小吗?
- (IBAction)cameraButtonPressed:(id)sender
{
if (! [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] ) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Error" message:@"no access to camera" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles: nil];
[alert show];
return;
}
UIImagePickerController *controller = [[UIImagePickerController alloc] init];
controller.delegate = self;
controller.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:controller animated:YES completion:nil];
}
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
[picker dismissViewControllerAnimated:YES completion:nil];
_imageView.image = image;
_imageView.contentMode = UIViewContentModeScaleAspectFit;
}
- (IBAction)save:(id)sender
{
Student *student = [NSEntityDescription insertNewObjectForEntityForName:@"Student"
inManagedObjectContext:self.managedObjectContext];
self.student.picdata = UIImagePNGRepresentation(_imageView.image);
[self.managedObjectContext save:nil];
[self.delegate DetailStudentSavePressed:self];
}
【问题讨论】:
标签: image performance core-data compression image-size