Action sheet doesn't display when the MFMailComposeViewController's cancel button is tapped

后端 未结 6 1028
醉话见心
醉话见心 2020-12-10 19:35

I\'m trying to incorporate MFMailComposeViewController in my app. When I present it modally, the send button works fine and the email is sent, which implies tha

6条回答
  •  情歌与酒
    2020-12-10 20:08

    Method

    (void)mailComposeController:(MFMailComposeViewController*)controller
            didFinishWithResult:(MFMailComposeResult)result
                          error:(NSError*)error
    

    is never called because you don't press any UIActionSheet button after cancelling, as it doesn't show on screen.

    The reason this is happening is that the UIActionSheet appears off-screen. If you check the debug log you'll probably see a message saying 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:]."

    That's why you see your view getting darker, but no UIActionSheet appears.

    In my case, the problem was that my app is universal, but for some reason there was only one MainWindow.xib, and it was larger than the iPhone screen size (it was, in fact, the iPad screen size).

    The solution is to create another MainWindow-iPhone.xib with the right dimensions and change the Info.plist entries called Main nib file base (iPad) and Main nib file base (iPhone) so that they point to the right file. Problem solved!

    Hope it helps.

提交回复
热议问题