Sn0wfreeze
Sn0wfreeze

Reputation: 2032

iOS 7.1 MFMailComposeViewController Error

I was coding a new iPhone App with iOS 7 and iOS 7.1 Beta 5. Not iOS 7.1 released for everybody and my MFMailComposeViewController isn't working anymore.

This is my code:

 MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
[mail setSubject:@"Test"];
[mail setToRecipients:@[@"[email protected]"]];
[mail setMessageBody:@"Test" isHTML:NO];
[mail setMailComposeDelegate:self];
[self presentViewController:mail animated:YES completion:nil];

Well I think that has to be a serious bug in iOS 7.1 What do you say?

I tried it again in a sample App, which could only present the mail view controller.

The Problem is that it doesn't allows the user to interact and it doesn't set the recipient and the message body. As you can see in my screenshot below: Screenshot MFMailComposeVC

EDIT: In the simulator it works perfectly! So please test it on a device

Greetings, Alexander Heinrich

Upvotes: 0

Views: 353

Answers (2)

Sertaç Nayci
Sertaç Nayci

Reputation: 11

 MFMailComposeViewController * mailim = [[MFMailComposeViewController alloc]init];
    [mailim setMailComposeDelegate:self];
    NSString * mailara =@"[email protected]";
    NSArray *emailArray = [[NSArray alloc]initWithObjects:mailara, nil];

    [mailim setToRecipients:emailArray];

    [mailim setSubject:@"Bilgi Almak Istiyorum"];

    [self presentViewController:mailim animated:YES completion:nil];

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

}

Upvotes: 1

Sn0wfreeze
Sn0wfreeze

Reputation: 2032

I fixed the problem by restarting the iPhone. Never came across with such problems before... I hope this won't occur more often

Upvotes: 0

Related Questions