0
在我的應用程序我用下面的代碼來處理從iPhone發送的消息我想知道如何讓他選擇與我們聯繫,並告訴朋友像其他應用程序我怎麼能使這個問題?如何讓用戶選擇郵件接收器?
代碼:
-(IBAction)sendEmail {
//Create a new mailComposer object and set the mailComposeDelegate (required).
MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init];
mailComposer.mailComposeDelegate = self;
if ([MFMailComposeViewController canSendMail]) {
//Set Fields such as Subject, recipients, and message body.
[mailComposer setToRecipients:[NSArray arrayWithObjects:@"[email protected]",nil]];
[mailComposer setSubject:@"App Feadback"];
//Present the mail view controller
[self presentModalViewController:mailComposer animated:YES];
}
//release the mailComposer as it is now being managed as the UIViewControllers modalViewController.
[mailComposer release];
}
//MFMailComposeControllerDelegate method that handles success or failure
//and dismisses the mailComposer
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
[self dismissModalViewControllerAnimated:YES];
if (result == MFMailComposeResultFailed) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Message Failed" message:@"Your message failed to send" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
}
您好我的意思是我可以使用此代碼,但當用戶觸摸按鈕發送郵件一半窗口出現告訴朋友或與我們聯繫,然後根據他所做的選擇我會填寫此代碼(info @ ... com)或(加號==添加郵件地址) – 2010-11-03 16:34:08
您可以使用UIActionSheet彈出帶有選項按鈕的半窗口。 – karim 2010-11-03 16:36:38