我在这里看到了很多问题关于拍照与此API的iOS拍照与图片选择内存泄漏
,但我遇到具体的问题
与下面的代码
.h文件中
@interface ComposeMViewController : UIViewController <UITextFieldDelegate , UITableViewDelegate ,UITableViewDataSource, UIImagePickerControllerDelegate , UINavigationControllerDelegate , MFMailComposeViewControllerDelegate , MFMessageComposeViewControllerDelegate , DistributionListViewControllerDelegate,UITextViewDelegate>
在.M
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
//UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
_imagePicker.delegate = self;
_imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:_imagePicker animated:YES completion:nil];
} else {
NSLog(@"Camera not available");
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSLog(@"At 1");
UIImage *fullImage = [info objectForKey:UIImagePickerControllerOriginalImage];
_attachment = [NSMutableDictionary dictionary];
NSData* imgData = UIImageJPEGRepresentation(fullImage,0.0);
[_attachment setObject:@"atachmentINFOR.jpg" forKey:@"ImageName"];
[_attachment setObject:imgData forKey:@"ImageData"];
NSLog(@"%@",info);
[self dismissViewControllerAnimated:YES completion:nil];//warning disabled
}
我正在收到内存警告,可以some1知道为什么?
它不回应(我没有这类型的警告) 以及第二次尝试工作正常,为画廊选择器 但对相机不:( –
你是不是有一个可用的相机(在真实设备上测试UIImagePickerController有一个允许测试的方法)? –
是的,我正在自己的手机上测试:) –