启动MFMailComposeViewController会切断收件人文本

时间:2012-01-26 18:47:47

标签: ios mfmailcomposeviewcontroller

我正在使用Apple的MessageUI和MFMailComposeViewControllerDelegate示例代码,而且大多数情况下效果很好。但由于某些原因,当我实现它时,收件人字段中的文本显示与字段标签不对齐,并且您只能在键入时看到光标的一半和文本的一半。键入地址并退出字段后,文本将完全可见,但仍与标签不一致。我查看了其他应用程序的MessageUI实现,但它们似乎没有这个问题。谁有人看到这个问题,并找到了解决方案?

以下是代码:

-(void)displayComposerSheet 
{
   MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];  
   picker.mailComposeDelegate = self;

   [picker setSubject:@"Data"];

   // Set up recipients
   NSArray *toRecipients = [NSArray arrayWithObject:@"email@example.com"]; 

   [picker setToRecipients:toRecipients];

   // Attach an attachment to the email
   NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
   NSString *documentsDirectory = [paths objectAtIndex:0];
   NSString *csvFile = [documentsDirectory stringByAppendingPathComponent:@"myFile.csv"];
   NSData *myData = [NSData dataWithContentsOfFile:csvFile];
   NSString *filename = @"myFile.csv";
   [picker addAttachmentData:myData mimeType:@"text/csv" fileName:filename];

   // Fill out the email body text
   NSString *emailBody = @"Attached is the data";
   [picker setMessageBody:emailBody isHTML:NO];

   [self presentModalViewController:picker animated:YES];

}

模拟器和设备都会出现问题。

1 个答案:

答案 0 :(得分:2)

您的应用中可能有一个自定义UITextField,并且在(CGRect)textRectForBounds:(CGRect)bounds中有一些自定义代码。如果您想要为UITextField课程设置一些类别,请尝试将您的特定代码直接放到您使用该类别的类而不是使用类别,这会影响应用中的所有文本字段,即使在{{1}中也是如此}

相关问题