我正在使用静态librrary,其中有一个使用UIImagePickerViewController
的类。我已将委托设置为它并在该类中编写didFinishPickingMediaWithInfo
:方法。我想要的是打开前置摄像头,在用户点击图像时捕获图像,然后将其保存到相册。我的代码发生的是UIImagePickerController
加载相机,当我点击"使用照片"按钮。但在那之后,它会冻结但不会崩溃。之后我无法点击任何地方。任何帮助赞赏。感谢
//图书馆代码
+ (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage* photo = (UIImage*) [info objectForKey:UIImagePickerControllerOriginalImage];
NSData *data = UIImagePNGRepresentation(photo);
photo = [UIImage imageWithCGImage:[UIImage imageWithData:data].CGImage
scale:photo.scale
orientation:photo.imageOrientation];
UIImageWriteToSavedPhotosAlbum(photo, self, nil, nil);
// TRIED ALL OF THE BELOW BUT NOTHING WORKS FOR ME
[picker dismissViewControllerAnimated:NO completion:nil];
// [picker dismissModalViewControllerAnimated:YES];
[picker.view.superview removeFromSuperview];
// [picker release];
// picker=nil;
}
答案 0 :(得分:0)
您的方法不应该是静态的 - 删除' +'并将其替换为' - '。
另外,在你做的方法
[picker.view.superview removeFromSuperview];
我不确定你想做什么!
所以你的代码变成了:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
...
}