First of all
#import <MessageUI/MessageUI.h>
And then
Mfmessagecomposeviewcontrollerdelegate
It's mostly here.
-(void) Showmessageview
{
if([mfmessagecomposeviewcontrollercansendtext]) {
Mfmessagecomposeviewcontroller * controller = [[mfmessagecomposeviewcontrolleralloc ]init]; //autorelease];
//controller.recipients = [Nsarray arraywithobject:@ "10010"];
Controller. Body =@ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
Controller. messagecomposedelegate =self;
[self presentviewcontroller: Controller animated:YES completion:nil];
[[[ Controller viewcontrollers]lastobject] navigationitem]settitle: @" xxxxxxxxxxx " ]; // Modify the text message interface title
}Else{
[selfalertwithtitle:@ " hint message "msg: @ " device does not have SMS function "];
}
}
Prompt information
-(void) Messagecomposeviewcontroller: (mfmessagecomposeviewcontroller *) controller Didfinishwithresult: (messagecomposeresult) result
{
[Controller dismissviewcontrolleranimated:NOcompletion:Nil ]; // the key sentence cannot be a YES
Switch (Result) {
casemessagecomposeresultcancelled:
[selfalertwithtitle:@ " message msg:@" send Cancel "];
break;
casemessagecomposeresultfailed://Send failed
[selfalertwithtitle:@ " message msg:@" sent successfully "];
break;
casemessagecomposeresultsent:
[selfalertwithtitle:@ " message msg:@" send failed "];
break;
default:
break;
}
}
System SMS Custom SMS