簡體   English   中英

iPhone應用程序在帶有圖像選擇器的iPad Retina中運行,但圖像選擇器對象為零

[英]iPhone app run in iPad Retina with image Picker but image picker Object is nil

這是iPhone應用程序代碼,但是當我遇到ipad視網膜模擬器或
iPad,然后它會使應用程序崩潰。 我已經檢查了很多次,我意識到
選擇器對象為nil。 但在iPhone模擬器上效果很好。 關於此事的任何想法。(此應用僅制作了iPhone,但可以在iPad Retina和iPad上運行)

UIImagePickerController * imagePicker = [[UIImagePickerController alloc] init]; // image picker alloc 
imagePicker.delegate = self; // delegate call by self

imagePicker.allowsEditing = YES;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; //Pick image in Library
[self presentModalViewController:imagePicker animated:YES]; // OPen Library


- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info                
{
    imgImage = info[UIImagePickerControllerOriginalImage]; //Get Orginial Images
    imgData = [[NSData alloc] initWithData:UIImageJPEGRepresentation((imgImage), 0.9)]; // Jpg image format
    [picker dismissModalViewControllerAnimated:YES];
} // pick image from this method

試試這個...當從庫中選擇圖像或從相機拍攝圖像時,將調用此方法。

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    UIImage *image = [info valueForKey:UIImagePickerControllerOriginalImage];
    NSData *imgData = UIImagePNGRepresentation(image);

    [picker dismissModalViewControllerAnimated:YES];

}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    [self dismissViewControllerAnimated:YES completion:NULL];
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM