ios - How to "invalidate" MFMessageComposeViewController (Obj-C) -
i have ibaction
opens text message dialog when pressed, using mfmessagecomposeviewcontroller
. have if
statement containing statements , want make mfmessagecomposeviewcontroller
"invalidated" if 1 of if statements true when pressed on same ibaction
.
so question simple, how "invalidate" mfmessagecomposeviewcontroller
? or @ least make dialog not appear?
edit (code):
if ([mfmessagecomposeviewcontroller cansendtext]) { nsmutablearray *recipients = [nsmutablearray array]; if (loadstring.length > 0) { [recipients addobject:loadstring]; } if (loadstring2.length > 0) { [recipients addobject:loadstring2]; } if (loadstring3.length > 0) { [recipients addobject:loadstring3]; } [controller setrecipients:recipients]; [controller setbody:thelocation]; [self presentviewcontroller:controller animated:yes completion:null]; } else { nslog(@"can't open text."); } }
thanks!
because mfmessagecomposeviewcontroller
instance of uiviewcontroller
. can dismiss using dismissviewcontrolleranimated
if don't want anymore.
and better handle mfmailcomposeviewcontrollerdelegate
, here sample code it:
- (void)mailcomposecontroller:(mfmailcomposeviewcontroller *)controller didfinishwithresult:(mfmailcomposeresult)result error:(nserror *)error { nslog(@"%@", error); switch (result) { case mfmailcomposeresultcancelled: { [controller dismissviewcontrolleranimated:yes completion:^(){ [svprogresshud showinfowithstatus:@"the email cancelled"]; }]; break; } case mfmailcomposeresultfailed: { [svprogresshud showerrorwithstatus:@"failed send"]; break; } case mfmailcomposeresultsaved: { [controller dismissviewcontrolleranimated:yes completion:^(){ [svprogresshud showerrorwithstatus:@"the draft saved"]; }]; break; } case mfmailcomposeresultsent: { [controller dismissviewcontrolleranimated:yes completion:^(){ [svprogresshud showsuccesswithstatus:@"sent successfully"]; }]; break; } default: break; } }
Comments
Post a Comment