Bloqueo de la aplicación al cerrar la vista del editor de correo en iphone sdk
Frecuentes
Visto 442 equipos
0
One of application i am using mail composer for sending mail but unfortunately when i click on send,save or cancel mail then application crash. Even application only support portrait mode and didn't implemented any code for change orientation. Code for Mail Composer method :-
MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
[mailViewController setMailComposeDelegate:self];
[mailViewController setToRecipients:[NSArray arrayWithObject:MAIL_EMAIL]];
[mailViewController setSubject:MAIL_SUBJECT];
[mailViewController setMessageBody:MAIL_MESSAGE isHTML:NO];
[self presentViewController:mailViewController animated:YES completion:^{
}];
Mail Composer Delegate Method :-
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;
}
[controller dismissViewControllerAnimated:YES completion:^{
}];
**Error** :-
*** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'preferredInterfaceOrientationForPresentation must return a supported interface orientation!'
*** First throw call stack:
(
0 CoreFoundation 0x0306d1e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x02dec8e5 objc_exception_throw + 44
2 CoreFoundation 0x0306cfbb +[NSException raise:format:] + 139
3 UIKit 0x01bdb3ec -[UIViewController _preferredInterfaceOrientationForPresentationInWindow:fromInterfaceOrientation:] + 580
4 UIKit 0x01e793d5 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:animation:] + 2330
5 UIKit 0x01bd8bda -[UIViewController _dismissViewControllerWithTransition:from:completion:] + 1647
6 UIKit 0x01bd852e -[UIViewController dismissViewControllerWithTransition:completion:] + 1281
7 UIKit 0x01bd852e -[UIViewController dismissViewControllerWithTransition:completion:] + 1281
8 UIKit 0x01bd9729 -[UIViewController dismissViewControllerAnimated:completion:] + 57
9 TestApp 0x0004c794 -[HelpViewController mailComposeController:didFinishWithResult:error:] + 340
10 MessageUI 0x019ba012 -[MFMailComposeInternalViewController _notifyCompositionDidFinish] + 535
11 MessageUI 0x019b9d98 -[MFMailComposeInternalViewController compositionFinishedWithResult:error:] + 210
12 MessageUI 0x019bbc5d -[MFMailComposeRemoteViewController serviceCompositionFinishedWithResult:error:] + 84
13 CoreFoundation 0x0306191d __invoking___ + 29
14 CoreFoundation 0x0306182a -[NSInvocation invoke] + 362
15 UIKit 0x020d5f0f __63-[_UIViewServiceInterface connection:handleInvocation:isReply:]_block_invoke + 36
16 libdispatch.dylib 0x0336c7b8 _dispatch_call_block_and_release + 15
17 libdispatch.dylib 0x033814d0 _dispatch_client_callout + 14
18 libdispatch.dylib 0x0336f726 _dispatch_main_queue_callback_4CF + 340
19 CoreFoundation 0x030d243e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
20 CoreFoundation 0x030135cb __CFRunLoopRun + 1963
21 CoreFoundation 0x030129d3 CFRunLoopRunSpecific + 467
22 CoreFoundation 0x030127eb CFRunLoopRunInMode + 123
23 GraphicsServices 0x040055ee GSEventRunModal + 192
24 GraphicsServices 0x0400542b GSEventRun + 104
25 UIKit 0x01aacf9b UIApplicationMain + 1225
26 TestApp 0x0001e30d main + 141
27 libdyld.dylib 0x035b670d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
1 Respuestas
0
Add the following code to your UIViewController subclass (the one you're using to present the mail composer)
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
-(BOOL)shouldAutorotate
{
return NO;
}
contestado el 28 de mayo de 14 a las 13:05
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas ios email or haz tu propia pregunta.
What's written in your info.plist under "supportedInterfaceOrientations"? - Stavash
Portrait (bottom home button) - Piyush
And you've added the above code to HelpViewController? - Stavash