我试图在有人通过 UIImagePickerController 选择照片后直接显示电子邮件对话框。之后我无法让它直接弹出。难道我做错了什么?最终我会将照片作为附件,但这不是困难的部分。我可以让电子邮件和照片模式单独显示,只是不会自动顺序显示。谢谢!
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
// Hide the dialouge
[picker dismissModalViewControllerAnimated:YES];
[self becomeFirstResponder];
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:@"test"];
[controller setMessageBody:@"test" isHTML:NO];
[self presentModalViewController:controller animated:YES];
最佳答案
因为您正在使用动画来隐藏您的图像选择器。
当您尝试显示 MFMailComposeViewController 时,UIImagePickerController 实际上并未被取消,这就是您收到错误的原因。
你可以改变你的代码
[picker dismissModalViewControllerAnimated:YES];
到
[picker dismissModalViewControllerAnimated:NO]; // (set Animated to "NO")
解决这个问题。
附言我也不确定你为什么要添加
[self becomeFirstResponder];
有,但好像没必要。
关于iphone - 在 UIImagePickerController 之后直接调用 MFMailComposeViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7061299/