我有一个客户在他的设备上测试一个应用程序,他使用的是带有 iOS 6.1.3 的 iPhone 3GS。
该应用程序包含一个简单的部分,您可以在其中共享有关该应用程序的信息等。
他报告的问题是,当邮件编写器打开 (presentViewController) 应用程序时,它会在邮件窗口显示后立即自动关闭。因此它会上升,然后再次直接下降,结果与取消电子邮件相同。
我完全不知道为什么只有这个单独的测试仪报告了这个问题。它在模拟器 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];
}