- (void) Showmessageviewwithtel: (NSString *) tel{if([Mfmessagecomposeviewcontroller Cansendtext]) {Mfmessagecomposeviewcontroller* Controller = [[Mfmessagecomposeviewcontroller alloc]init];//Autorelease];controller.recipients=[Nsarray Arraywithobject:tel]; Controller.body=@""; Controller.messagecomposedelegate=Self ; [Self Presentviewcontroller:controller animated:yes completion:nil]; [[[Controller viewcontrollers] lastobject] navigationitem] Settitle:@"Test SMS"];//Modify the text message interface title}Else{[Self alertwithtitle:@"Prompt Information"Msg@"device does not have SMS function"]; }}//mfmessagecomposeviewcontrollerdelegate- (void) Messagecomposeviewcontroller: (Mfmessagecomposeviewcontroller *Controller Didfinishwithresult: (messagecomposeresult) result{[controller dismissviewcontrolleranimated:no com Pletion:nil];//The key sentence cannot be Yes Switch(Result) { Casemessagecomposeresultcancelled: [Self alertwithtitle:@"Prompt Information"Msg@"Send Cancel"]; Break; CaseMessagecomposeresultfailed://Send failed[Self Alertwithtitle:@"Prompt Information"Msg@"Send failed"]; Break; Casemessagecomposeresultsent: [Self alertwithtitle:@"Prompt Information"Msg@"sent successfully"]; Break; default: Break; }}- (void) Alertwithtitle: (NSString *) title msg: (NSString *) msg {Uialertview*alert =[[Uialertview alloc] Initwithtitle:title message:msg Delegate: Self Cancelbuttontitle:nil otherbut Tontitles:@"Determine", nil]; [Alert show]; }
IOS sends SMS in the current controller