HomeiOS DevelopmentiPad would not present Cancel button anymore for MFMailComposeViewController

iPad would not present Cancel button anymore for MFMailComposeViewController


I have been creating an app which makes use of MFMailComposeViewController to ship precomposed emails. I have been utilizing the identical presentation methodology for ages (a minimum of 10 years) however on iPads, since a few iOS variations, the Cancel (‘X’) button just isn’t proven anymore within the navigation bar, so the customers can not exit the ‘Ship mail’ dialog (besides by sending the e-mail, or killing the app).

  • Every part is up to date to the newest OS and Xcode variations (26.5)
  • iPhones are usually not affected, it solely happens on iPads.
  • An outdated iPad with iOS 16.7, with a current TestFlight model of the app, nonetheless exhibits a button with the phrase ‘Cancel’ on the highest left, even when I do a contemporary set up from Xcode. In contrast to iOS 26, the ‘Ship’ button (an icon, similar to iOS 26) and title are horizontally aligned, and the ‘Cancel’ button is proven above each of them.

My workaround is to make use of UIModalPresentationPageSheet which nonetheless would not present a cancel button, however does permit to cancel the dialog by tapping outdoors of it.


To breed, create a brand new Venture with interface Storyboard, language Goal-C.
Change ViewController.h in order that it implements the mail compose delegate and is aware of the best way to obtain a button click on:

@interface ViewController : UIViewController <MFMailComposeViewControllerDelegate>

- (IBAction)buttonClicked:(id)sender;

@finish

Within the storyboard, add an UIButton with occasion touchUpInside linked to buttonClicked.

Inside ViewController.m, add this:

- (IBAction)buttonClicked:(id)sender {
    MFMailComposeViewController *mailComposer = [MFMailComposeViewController new];
    mailComposer.mailComposeDelegate = self;
    mailComposer.modalPresentationStyle = UIModalPresentationFullScreen;
    [self presentViewController:mailComposer animated:YES completion:NULL];
}

- (void)mailComposeController:(MFMailComposeViewController *)controller
          didFinishWithResult:(MFMailComposeResult)end result
                        error:(NSError *)error {
    [self dismissViewControllerAnimated:YES completion:NULL];
}

(in case you do not set mailComposeDelegate, the X button will nonetheless present on iPhone however do not do something)


iPhone screenshot:

iPad would not present Cancel button anymore for MFMailComposeViewController

iPad screenshot:

iPad screenshot

(FWIW, I went right into a debugging session with an AI mannequin; it instructed me half a dozen issues to strive, being assured that it discovered the true subject at each step, however none of its strategies labored. I doubt it is value sharing, it lastly appeared to agree "that it is a bug launched within the iOS 26 format engine.")

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments