I am using MFMailComposeViewController for sending feedback in my app. It works fine. But the problem here is, the user can edit/delete the "to" address. I want to make it as a n开发者_如何学运维on-editable one. May be, the user can add some mail addresses in "to" field.
But he/she should not delete the feedback address (Here, it is "support@xxxx.com").
Here is my code...
MFMailComposeViewController *composeWindow = [[MFMailComposeViewController alloc] init];
composeWindow.mailComposeDelegate = self;
NSString *str = @"Subject of the feedback";
[composeWindow setSubject:[str stringByAppendingString:[[UIDevice currentDevice]systemVersion]]];
NSArray *toRecipients = [NSArray arrayWithObject: @"support@xxxx.com"];
[composeWindow setToRecipients:toRecipients];
[self presentModalViewController:composeWindow animated:YES];
[composeWindow release];
Thanks in Advance
Rajkanth
You can not customize MFMailComposeViewController
to avoid editing. Apple forbids this, and the reason is quite simple: it is the user and not you that must decide exactly what to send, to whom etc. The same applies for the UI controller allowing to send SMS (text) messages. And, of course, Apple does not allows sending an email or SMS without explicit interaction with the user. It is the user that must validate and send the email or SMS message. The validation process include the ability to cancel the message or to change any single property at will, including the "to" recipients.
All the other answers are correct. You can not change the interface of the MFMailComposeViewController. But you have other possibilities. ;-)
Three20 SDK includes also an Mail Composer. Try it out. I think it should be that far changeable, that the "to" field is not editable anymore.
I hope my answer is helpful for you.
Sandro Meier
EDIT
Three20 SDK was discontinued a while ago. So you shouldn't use it anymore for new projects. I advise you to use NimbusKit instead. This is also recommended by the Three20 SDK team. Sadly it does not include a MailComposeViewController
From the Apple documentation:
Important: The mail composition interface itself is not customizable and must not be modified by your application. In addition, after presenting the interface, your application is not allowed to make further changes to the email content. The user may still edit the content using the interface, but programmatic changes are ignored. Thus, you must set the values of content fields before presenting the interface.
精彩评论