2

From a tableview I want to present a MFMailComposeViewController. I don't want to use the presentModalViewController:animated: method, but instead push the view controller, so it's consistent with the other animations from this table view.

Because MFMailComposeViewController is a UINavigationController and pushing a navigation controller is not supported, I used:

[[self navigationController] pushViewController:[mailComposer topViewController] animated:YES];

This works, but when I tap the Cancel button it gives the warning:

Presenting action sheet clipped by its superview. Some controls might not respond to touches. On iPhone try -[UIActionSheet showFromTabBar:] or -[UIActionSheet showFromToolbar:] instead of -[UIActionSheet showInView:].

The Cancel button at the bottom of the UIActionSheet doesn't respond to touches. Does anyone know whether it is possible to push a MFMailComposeViewController?

Marco
  • 330
  • 5
  • 13
  • 1
    You already answer your question - _MFMailComposeViewController is a UINavigationController and pushing a navigation controller is not supported_ – beryllium Nov 28 '11 at 17:03
  • But you can push MFMailComposeViewController's UIViewController. Or is this not supported? – Marco Nov 28 '11 at 17:15
  • You code pushes UIViewController (topViewController returns it). It's a normal behavior. – beryllium Nov 28 '11 at 17:19
  • Yes I know, but downside is the UIActionSheet warning when you use the MailComposer's cancel button. So it doesn't seem supported or I'm missing a step (like telling this view controller to use [self navigationController] as it's navigationController). – Marco Nov 28 '11 at 17:33
  • I think this UIActionSheet called from navigation which contains MailComposer and this action sheet cann't find (or do) something because you have only part of navigation hierarchy (missing navigationBar or toolBar). – beryllium Nov 28 '11 at 17:38

1 Answers1

5

Presenting a MFMailComposeViewController as a modal view is consistent with Apple's HIG. Pushing it onto a navigation stack is not. Use -presentModalViewController:animated: (or -presentViewController:animated:completion: if executing on iOS 5 or greater)

gschandler
  • 3,208
  • 16
  • 16
  • Thanks for your answer. OK, so there's no way animate a MailComposer right to left? It seems a bit weird that this animation is not supported. I don't think it's clear for the user why the "Send email" function animates from the top and all the other functions from this tableview are animated with a right to left push. – Marco Nov 28 '11 at 17:28
  • 1
    You can use `UIModalTransitionStyleFlipHorizontal` as well. Otherwise, the right to left transition is intended for indicating the user is drilling down into the information hierarchy. Presenting the mail composer is intended to be a "break in the action" and is intended to be a modal action. Grabbing the view controller hierarchy from a self contained `UINavigationController` component is a receipt for a broken application down the road should Apple change its behavior or structure. – gschandler Nov 28 '11 at 17:56
  • 2
    For future knowledge, `presentModalViewController:animated:` has been deprecated by Apple, so you should use `presentViewController:animated:completion:` instead. –  Sep 24 '12 at 11:10