У меня возникают проблемы при попытке сделать более 1 фотографии. Приложение становится медленным, а затем вылетает из-за нескольких предупреждений о памяти. Я использую библиотеку Брэда GPUImage. Вот несколько методов, в которых я его использую:
//создание вида камеры
- (IBAction)photoFromCamera
{
imageView = [[GPUImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
imageView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:imageView];
stillCamera = [[GPUImageStillCamera alloc] init];
stillCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
//stillCamera.outputImageOrientation = UIInterfaceOrientationLandscapeLeft;
filter = [[GPUImageFilter alloc] init];
[filter prepareForImageCapture];
[stillCamera addTarget:filter];
[stillCamera addTarget:imageView];
[filter addTarget:imageView];
[stillCamera startCameraCapture];
UIButton * shotButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
shotButton.frame = CGRectMake(137, 361, 46, 30);
[shotButton setTitle:@"Take!" forState:UIControlStateNormal];
[shotButton addTarget:self action:@selector(shotAction:) forControlEvents:UIControlEventTouchUpInside];
[imageView addSubview:shotButton];
UIButton * cancelButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
cancelButton.frame = CGRectMake(10, 80, 55, 40);
[cancelButton setTitle:@"cancel" forState:UIControlStateNormal];
[cancelButton addTarget:self action:@selector(cancelAction) forControlEvents:UIControlEventTouchUpInside];
[imageView addSubview:cancelButton];
}
// Действие «сделать фото»
-(void)shotAction:(UIImagePickerController *)photoPicker{
[stillCamera capturePhotoAsPNGProcessedUpToFilter:filter withCompletionHandler:^(NSData *processedPNG, NSError *error) {
self.saveButton.enabled = YES;
self.filterButton.enabled = YES;
self.cropButton.enabled = YES;
originalFirstImage = [UIImage imageWithData:processedPNG];
[self.selectedImageView setImage:originalFirstImage];
}];
[imageView removeFromSuperview];
}
здесь что-то не так? Я использую ARC, что-то не выходит? Спасибо за ваши комментарии.
РЕДАКТИРОВАТЬ: ошибка: Завершено из-за нехватки памяти
property(nonatomic, weak) IBOutlet UIBarButtonItem *filterButton; property(nonatomic, weak) IBOutlet UIBarButtonItem *saveButton; property (nonatomic, weak) IBOutlet UIButton *cropButton;
должен ли я изменить их на переменные класса? - person Vergmort   schedule 16.01.2014