I have.... actually ill just paste some code.
.H
Code:
#import <UIKit/UIKit.h>
#import <MessageUI/MFMailComposeViewController.h>
@interface ViewController : UIViewController<UIAlertViewDelegate,MFMailComposeViewControllerDelegate>
...
@end
.M
Code:
called from a button
...{MFMessageComposeViewController *smsController = [[MFMessageComposeViewController alloc]init];
if ([MFMessageComposeViewController canSendText]) {
smsController.body=[[alert textFieldAtIndex:0]text];
smsController.recipients = [NSArray arrayWithObjects: @"kMYSMS",nil];
smsController.messageComposeDelegate =nil;
[self presentModalViewController:smsController animated:YES];
}
-(void)messageComposeViewController:(MFMessageComposeViewController *)smsController didFinishWithResult:(MessageComposeResult)result {
if(result == MessageComposeResultCancelled) {
//Message cancelled
} else if(result == MessageComposeResultSent) {
//Message sent
}
[self dismissModalViewControllerAnimated:YES];
}
first question is i want to add some other text into the message body field
i.e "some initial text here" and then [alert textFieldAtIndex:0]text].
When i try and send text on my device it launches the sms app but slowly, it then instantly dismisses the keyboard and text input field. I have to click on top To: field to bring the compose box back on screen. I also must send the sms and the cancel button does not work.
so second question is how can i enable the cancel button once sms is launched
or better still how can I prevent the sms app being launched and just send the sms direct from the uialertview that initializes it?