Xcode 不兼容的指针类型传递“;UIImagePickerController*”;至类型为“的参数”;UIImage*”;

Xcode 不兼容的指针类型传递“;UIImagePickerController*”;至类型为“的参数”;UIImage*”;,xcode,xcode4.3,Xcode,Xcode4.3,我对Xcode非常陌生,我正在尝试编写一个应用程序,允许用户使用相机,拍摄多张照片,然后允许用户选择要附加到应用程序内电子邮件的照片。 我遇到了如下错误: Incompatible pointer types passing "UIImagePickerController *" to parameter of type "UIImage *" 及 及 及 这是我的密码 // Camera Control -(void) takePhotoClicked { if ([UIImage

我对Xcode非常陌生,我正在尝试编写一个应用程序,允许用户使用相机,拍摄多张照片,然后允许用户选择要附加到应用程序内电子邮件的照片。 我遇到了如下错误:

Incompatible pointer types passing "UIImagePickerController *" to parameter of type "UIImage *"

这是我的密码

// Camera Control

-(void) takePhotoClicked
{
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])

    {
        UIImagePickerController *theimagepicker = [[UIImagePickerController alloc] init];

        theimagepicker.delegate = self;

        theimagepicker.sourceType = UIImagePickerControllerSourceTypeCamera;
        theimagepicker.mediaTypes = @[(NSString *) kUTTypeImage] ;
        theimagepicker.allowsEditing = NO;
        [self presentModalViewController:theimagepicker animated:YES];
        [theimagepicker release];
        newMedia = YES;

    }
}

// Choose Photo Control

-(void) choosePhotoClicked
{
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum])
    {
        UIImagePickerController *theimagepicker = [[UIImagePickerController alloc] init];

        theimagepicker.delegate = self;

        theimagepicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

        theimagepicker.mediaTypes = @[(NSString *) kUTTypeImage];
        theimagepicker.allowsEditing = NO;
        [self presentModalViewController:theimagepicker animated:YES];
        // Save image
        UIImageWriteToSavedPhotosAlbum(theimagepicker, self, @selector(theimagepicker:didFinishSavingWithError:contextInfo:), nil);
        NSLog(@"Creating Mail Data!!!");
        NSData *photoData = [[UIImageJPEGRepresentation([UIImage imageNamed:@"qwerty.png"], 1) alloc] init];

        [theimagepicker release];
        newMedia = NO;

    }
}



// Image Delegate Methods

-(void)theimagepickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo: (NSDictionary *)info
{
    NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
    [self dismissModalViewControllerAnimated:YES];
    if ([mediaType isEqualToString:(NSString *)kUTTypeImage])
    {
        UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];

        theimageView.image = image;
        if (newMedia)
            UIImageWriteToSavedPhotosAlbum(image, self, @selector (image:finishedSavingWithError:contextInfo:), nil);


        NSLog(@"Creating Mail Data!!!");
        NSData *photoData = [[UIImageJPEGRepresentation([UIImage imageNamed:@"qwerty.png"], 1) alloc] init];


    }
    else if ([mediaType isEqualToString:(NSString *) kUTTypeMovie])
    {


        // Code here to support video if enabled
    }
}

-(void)image:(UIImage *)image
finishedSavingWithError:(NSError *)error
 contextInfo:(void *)contextInfo
{
    if (error) {
        UIAlertView *alert = [[UIAlertView alloc]
                              initWithTitle: @"Save failed"
                              message: @"Failed to save image"
                              delegate: nil
                              cancelButtonTitle:@"OK"
                              otherButtonTitles:nil];
        [alert show];
        [alert release];

    }

}

// Email Control
#pragma mark - Open the mail interface
-(IBAction)email
{
    MFMailComposeViewController *composer = [[MFMailComposeViewController alloc] init];
    [composer setMailComposeDelegate:self];
    if([MFMailComposeViewController canSendMail])
    {
        //  NSString *custemail = txtCustomerEmail.text;

        //  NSArray *toRecipients = [NSArray arrayWithObject:custemail];
        // [composer setToRecipients:toRecipients];

        [composer setSubject:@"Title Search results:"];

        [composer addAttachmentData:photoData mimeType:@"image/jpg" fileName:[UIImage imageNamed:theimageView.image]];




        // Fill out the email body text
        NSString *emailBody =[NSString stringWithFormat:@"Examiner Name :%@\nExaminer Address :%@\nExaminer City :%@\nExaminer State :%@\nExaminer Zip Code :%@\nExaminer Email Address :%@\nCustomer Name :%@\nCustomer Address :%@\nCustomer City :%@\nCustomer State :%@\nCustomer Zip Code :%@\nCustomer Email Address :%@\nSearch Through Date :%@\nTitle Held By :%@\nProperty Address :%@\nProperty City :%@\nProperty State :%@\nProperty Zip Code :%@\nProperty County : %@\nTitle Search Notes :%@\nMortgage 1 Lender :%@\nMortgage 1 Dated :%@\nMortgage 1 Recorded :%@\nMortgage 1 Amount :%@\nMortgage 1 Book Number :%@\nMortgage 1 Page Number :%@\nMortgage 1 Assignment :%@\nMortgage 1 Additional Info :%@\nMortgage 2 Lender :%@\nMortgage 2 Dated :%@\nMortgage 2 Recorded :%@\nMortgage 2 Amount :%@\nMortgage 2 Book Number :%@\nMortgage 2 Page Number :%@\nMortgage 2 Assignment :%@\nMortgage 2 Additional Info :%@\nMortgage 3 Lender :%@\nMortgage 3 Dated :%@\nMortgage 3 Recorded :%@\nMortgage 3 Amount :%@\nMortgage 3 Book Number :%@\nMortgage 3 Page Number :%@\nMortgage 3 Assignment :%@\nMortgage 3 Additional Info :%@\nLien/Judgement 1 Creditor :%@\nLien/Judgement 1 Type ;%@\nLien/Judgement 1 Dated :%@\nLien/Judgement 1 Recorded :%@\nLien/Judgement 1 Amount :%@\nLien/Judgement 1 Book Number :%@\nLien/Judgement 1 Page Number :%@\nLien/Judgement 1 Notes :%@\nLien/Judgement 2 Creditor :%@\nLien/Judgement 2 Type ;%@\nLien/Judgement 2 Dated :%@\nLien/Judgement 2 Recorded :%@\nLien/Judgement 2 Amount :%@\nLien/Judgement 2 Book Number :%@\nLien/Judgement 2 Page Number :%@\nLien/Judgement 2 Notes :%@\nLien/Judgement 3 Creditor :%@\nLien/Judgement 3 Type ;%@\nLien/Judgement 3 Dated :%@\nLien/Judgement 3 Recorded :%@\nLien/Judgement 3 Amount :%@\nLien/Judgement 3 Book Number :%@\nLien/Judgement 3 Page Number :%@\nLien/Judgement 3 Notes :%@\nProperty Tax ID :%@\nProperty Tax Amount :%@\nHow Often Are Taxes Paid :%@\nNext Payment Due Date :%@\nNext Payment Due Amount :%@\nExaminers' Notes Line 1:%@\nExaminers' Notes Line 2:%@\nExaminers' Notes Line 3:%@\nExaminers' Notes Line 4:%@\nExaminers' Notes Line 5:%@\nExaminers' Notes Line 6:%@\nExaminers' Notes Line 7:%@\nExaminers' Notes Line 8:%@\nExaminers' Notes Line 9:%@\nExaminers' Notes Line 10:%@\nLegal Description Line 1 :%@\nLegal Description Line 2 :%@\nLegal Description Line 3 :%@\nLegal Description Line 4 :%@\nLegal Description Line 5 :%@\nLegal Description Line 6 :%@\nLegal Description Line 7 :%@\nLegal Description Line 8 :%@\nLegal Description Line 9 :%@\nLegal Description Line 10 :%@\nLegal Description Line 11 :%@\nLegal Description Line 12 :%@\nLegal Description Line 13 :%@\nLegal Description Line 14 :%@\nLegal Description Line 15 :%@\nLegal Description Line 16 :%@\nLegal Description Line 17 :%@\nLegal Description Line 18 :%@\nLegal Description Line 19 :%@\nLegal Description Line 20 :%@\nLegal Description Line 21 :%@\nLegal Description Line 22 :%@\nLegal Description Line 23 :%@\nLegal Description Line 24 :%@\nLegal Description Line 25 :%@\nLegal Description Line 26 :%@\nLegal Description Line 27 :%@\nLegal Description Line 28 :%@\nLegal Description Line 29 :%@\nLegal Description Line 30 :%@", txtExaminerName.text, txtExaminerAddress.text, txtExaminerCity.text, txtExaminerState.text, txtExaminerZip.text, txtExaminerEmail.text, txtCustomerName.text, txtCustomerAddress.text, txtCustomerCity.text, txtCustomerState.text, txtCustomerZip.text, txtCustomerEmail.text, txtSearchThroughDate.text, txtTitleHeldBy.text, txtPropertyAddress.text, txtPropertyCity.text, txtPropertyState.text, txtPropertyZip.text, txtTitleSearchNotes.text, txtMtg1LenderName.text, txtMtg1Dated.text, txtMtg1Recorded.text, txtMtg1Amount.text, txtMtg1BookNumber.text, txtMtg1BookNumber.text, txtMtg1PageNumber.text, txtMtg1Assignment.text, txtMtg1AddlInfo.text, txtMtg2LenderName.text, txtMtg2Dated.text, txtMtg2Recorded.text, txtMtg2Amount.text, txtMtg2BookNumber.text, txtMtg2PageNumber.text, txtMtg2Assignment.text, txtMtg2AddlInfo.text, txtMtg3LenderName.text, txtMtg3Dated.text, txtMtg3Recorded.text, txtMtg3Amount.text, txtMtg3BookNumber.text, txtMtg3PageNumber.text, txtMtg3Assignment.text, txtMtg3AddlInfo.text, txtLien1Creditor.text, txtLien1Type.text, txtLien1Dated.text, txtLien1Recorded.text, txtLien1Amount.text, txtLien1BookNumber.text, txtLien1PageNumber.text, txtLien1Notes.text, txtLien2Creditor.text, txtLien2Type.text, txtLien2Dated.text, txtLien2Recorded.text, txtLien2Amount.text, txtLien2BookNumber.text, txtLien2PageNumber.text, txtLien2Notes.text, txtLien3Creditor.text, txtLien3Type.text, txtLien3Dated.text, txtLien3Recorded.text, txtLien3Amount.text, txtLien3BookNumber.text, txtLien3PageNumber.text, txtLien3Notes.text, txtPropertyTaxID.text, txtPropertyTaxAmount.text, txtHowTaxesArePaid.text, txtNextPaymentDueDate.text, txtNextPaymentAmount.text, txt1ExaminersNotes.text, txt2ExaminersNotes.text, txt3ExaminersNotes.text,txt4ExaminersNotes.text, txt5ExaminersNotes.text, txt6ExaminersNotes.text,txt7ExaminersNotes.text, txt8ExaminersNotes.text, txt9ExaminersNotes.text,txt10ExaminersNotes.text, txt1LegalDescription.text, txt2LegalDescription.text, txt3LegalDescription.text, txt4LegalDescription.text, txt5LegalDescription.text, txt6LegalDescription.text, txt7LegalDescription.text, txt8LegalDescription.text, txt9LegalDescription.text, txt10LegalDescription.text, txt11LegalDescription.text, txt12LegalDescription.text, txt13LegalDescription.text, txt14LegalDescription.text, txt15LegalDescription.text, txt16LegalDescription.text, txt17LegalDescription.text, txt18LegalDescription.text, txt19LegalDescription.text, txt20LegalDescription.text, txt21LegalDescription.text, txt22LegalDescription.text, txt23LegalDescription.text, txt24LegalDescription.text, txt25LegalDescription.text, txt26LegalDescription.text, txt27LegalDescription.text, txt28LegalDescription.text, txt29LegalDescription.text, txt30LegalDescription.text];

        //

        [composer setMessageBody:emailBody isHTML:NO];

        composer.modalPresentationStyle = UIModalPresentationPageSheet;

        [self presentModalViewController:composer animated:YES];

        [composer release];
    }
    else
        [composer release];
}

-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
    if (error)
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"error"

                                                        message:[NSString stringWithFormat:@"error %@", [error description]]

                                                       delegate:nil cancelButtonTitle:@"dismiss" otherButtonTitles:nil, nil];


        [alert show];
        [alert release];

        [self dismissModalViewControllerAnimated:YES];

    }
    else {
        [self dismissModalViewControllerAnimated:YES];
    }
}
好的,在方法“choosePhotoClicked”中删除这些行

    UIImageWriteToSavedPhotosAlbum(theimagepicker, self, @selector(theimagepicker:didFinishSavingWithError:contextInfo:), nil);

    NSData *photoData = [[UIImageJPEGRepresentation([UIImage imageNamed:@"qwerty.png"], 1) alloc] init];
然后从“didFinishPicking…”中删除此行

然后在“电子邮件”操作中替换此行:

    [composer addAttachmentData:photoData mimeType:@"image/jpg" fileName:[UIImage imageNamed:theimageView.image]];
以下几行:

    NSData *imageData = UIImageJPEGRepresentation(theimageView.image, 1.0);
    [composer addAttachmentData:imageData mimeType:@"image/jpg" fileName:@"this is a string file name";

可以您从何处获得这些错误?在[composer addAttachmentData:photoData mimeType:@“image/jpg”文件名:[UIImage ImageName:theimageView.image]]行;我获取不兼容的指针类型,将“UIImage*”发送到NSData*photoData=[[UIImageJPEGresentation([UIImage ImageName:@“qwerty.png”],1)alloc]init]行上类型为“NSString*”的参数两次;我得到的实例方法'-alloc'未找到(返回类型默认为'id')以及未使用的变量'photoData',以及在初始化过程中存储到'photoData'的值永远不会在[theimagepicker release]行读取;我在fieldArray=@[[NSString stringWithFormat:@“%@”,TxtXaminerName.text]行获取存储到“photoData”中的对象的潜在泄漏,我得到了存储到“fieldArray”的值从未读过谢谢!!!只是一个简单的问题…这允许我现在选择多个图像并将它们附加到我的电子邮件中吗?@user1539154很高兴提供帮助,只要我的回答对你有帮助,请确保将其标记为正确。它是我帖子旁边的复选标记图标。只要你创建新的NSF数据实例或者一个多个附件就可以了。不过我不确定一封电子邮件的最大大小是多少。
    UIImageWriteToSavedPhotosAlbum(theimagepicker, self, @selector(theimagepicker:didFinishSavingWithError:contextInfo:), nil);

    NSData *photoData = [[UIImageJPEGRepresentation([UIImage imageNamed:@"qwerty.png"], 1) alloc] init];
    NSData *photoData = [[UIImageJPEGRepresentation([UIImage imageNamed:@"qwerty.png"], 1) alloc] init];
    [composer addAttachmentData:photoData mimeType:@"image/jpg" fileName:[UIImage imageNamed:theimageView.image]];
    NSData *imageData = UIImageJPEGRepresentation(theimageView.image, 1.0);
    [composer addAttachmentData:imageData mimeType:@"image/jpg" fileName:@"this is a string file name";