presentViewController没有显示邮件作曲家表

时间:2013-03-20 11:25:06

标签: objective-c mfmailcomposeviewcontroller

presentViewController未显示邮件模态视图控制器。我已经从presentmodalviewcontroller更改为presentViewController,但它没有给出任何错误,也没有呈现模态视图。如何解决这个问题?

    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc]init];
    picker.mailComposeDelegate = self; 
    picker.navigationBar.tintColor = [UIColor colorWithHue:0.6 saturation:0.33 brightness:0.69 alpha:0];
    NSString *lObjstringPtr = (NSString *)nil;

    if(OPPORTUNITY_ENTITY_OBJECT_TYPE_CODE==m_cobjOwningGroup.m_cObjSelectedEntity.m_cObjectTypeCode) {
        lObjstringPtr = [lObjstringPtr stringByAppendingFormat:@" To Follow Up"];
        [picker setSubject:lObjstringPtr];
        lObjstringPtr = (NSString *)nil;
    } else 
        [picker setSubject:@""];

        [picker setMessageBody:m_cObjemailBodyStrPtr isHTML:NO];
        NSArray *toRecipients = [NSArray arrayWithObject:pEmailID];
        [picker setToRecipients:toRecipients];
        [self presentViewController:picker animated:YES completion:nil]; 
        [picker release];

1 个答案:

答案 0 :(得分:0)

两件事,一件针对这种情况,一件是一般性的。

  1. 您似乎没有检查设备上是否设置了邮件。在您尝试显示邮件视图之前,您应该检查[MFMailComposeViewController canSendMail]的返回值,并仅显示控制器YES
  2. 未显示视图的常见情况是控制器为nil。在presentViewController:之前,您可能需要检查(使用NSLog或使用调试程序)picker不为零。