我有一个客户端在他的设备上测试应用程序,他正在使用带有iOS 6.1.3的iPhone 3GS。
该应用包含一个简单的部分,您可以在其中分享有关应用的信息等信息。
他报告的问题是,当邮件编辑器打开(presentViewController)时,应用程序会在显示后立即自动关闭邮件窗口。所以它会上升,然后再次直接下调,结果与您取消电子邮件的结果相同。
我完全不知道为什么只有这个singel测试仪报告了这个问题。它在模拟器iOS 6.1和7.0上运行良好,它在iPhone 4,4S和5等所有其他设备上运行良好。这是代码,也许我做错了3GS无法编译:
#pragma mark - Share to mail
// Share mail button
- (IBAction)shareTo_mail_BtnClicked:(id)sender
{
[HUD showUIBlockingIndicatorWithText:@"Laddar mail"];
// Email Subject
NSString *emailTitle = PROMO_TEXT;
// Email Content
NSString *messageBody = SHARED_INFO_TEXT;
// If mail account can't bee found
if(![MFMailComposeViewController canSendMail]) {
[HUD hideUIBlockingIndicator];
// Alert the user that no mail account is connected to the phone
UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:@"Ett fel inträffade" message:@"Kontrollera att du har ett mail-konto anslutet till telefonen." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[warningAlert show];
return;
}else {
NSLog(@"Mail account found!");
}
MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
mc.mailComposeDelegate = self;
[mc setSubject:emailTitle];
[mc setMessageBody:messageBody isHTML:NO];
[self presentViewController:mc animated:YES completion:nil];
[HUD hideUIBlockingIndicator];
}
// Mail did finish with result
- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
switch (result)
{
case MFMailComposeResultCancelled:
NSLog(@"Mail cancelled");
break;
case MFMailComposeResultSaved:
NSLog(@"Mail saved");
break;
case MFMailComposeResultSent:
NSLog(@"Mail sent");
break;
case MFMailComposeResultFailed:
NSLog(@"Mail sent failure: %@", [error localizedDescription]);
break;
default:
break;
}
// Close the Mail Interface
[self dismissViewControllerAnimated:YES completion:nil];
}