ios - MFMailComposeViewController not working on device , instance printed on console output is <register sp is not available> -
i have created utility class called mailcomposeviewcontroller cllling class other view controller, mail composer working on simulater is crashing on device.
this way calling function
nslog(@"mail"); mailcomposeviewcontroller *mailcomposer =[[mailcomposeviewcontroller alloc]init]; [mailcomposer showpicker:self andimage:md.img_savedimageaftereffect];
below utility class contains code send mail functionility
#import "mailcomposeviewcontroller.h" uiviewcontroller *controller; @implementation mailcomposeviewcontroller -(void)showpicker:(id)viewcontroller andimage:(uiimage*)image; { controller = viewcontroller; class mailclass = (nsclassfromstring(@"mfmailcomposeviewcontroller")); if (mailclass != nil) { // must check whether current device configured sending emails if ([mailclass cansendmail]) { [self displaycomposersheet:viewcontroller andimage:image]; } else { //[self launchmailappondevice]; [self displaycomposersheet:viewcontroller andimage:image]; } } else { //[self launchmailappondevice]; [self displaycomposersheet:viewcontroller andimage:image]; } } -(void)displaycomposersheet:(id)viewcontroller andimage:(uiimage*)image { mfmailcomposeviewcontroller *picker = [[mfmailcomposeviewcontroller alloc] init]; picker.mailcomposedelegate = self; nsdata *mydata = uiimagejpegrepresentation(image,0.9); [picker addattachmentdata:mydata mimetype:@"image/jpg" filename:@""]; picker.modalpresentationstyle = uimodalpresentationformsheet; picker.modaltransitionstyle = uimodaltransitionstylecoververtical; [viewcontroller presentmodalviewcontroller:picker animated:yes]; [picker release]; } // dismisses email composition interface when users tap cancel or send. proceeds update message field result of operation. - (void)mailcomposecontroller:(mfmailcomposeviewcontroller*)controller didfinishwithresult: (mfmailcomposeresult)result error:(nserror*)error { //message.hidden = no; // notifies users errors associated interface switch (result) { case mfmailcomposeresultcancelled: // message.text = @"result: canceled"; break; case mfmailcomposeresultsaved: // message.text = @"result: saved"; break; case mfmailcomposeresultsent: //message.text = @"result: sent"; break; case mfmailcomposeresultfailed: // message.text = @"result: failed"; break; default: // message.text = @"result: not sent"; break; } [controller dismissmodalviewcontrolleranimated:yes]; } - (void)viewdidload { [super viewdidload]; // additional setup after loading view. } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } @end
crash report uikit`-[uiviewcontroller presentmodalviewcontroller:animated:]: 0x3a4d5238: push {r7, lr} 0x3a4d523a: mov r7, sp 0x3a4d523c: sub sp, #4 0x3a4d523e: movw r1, #18934 0x3a4d5242: mov.w r9, #0 0x3a4d5246: movt r1, #525 0x3a4d524a: str.w r9, [sp] 0x3a4d524e: add r1, pc 0x3a4d5250: ldr r1, [r1] 0x3a4d5252: blx 0x3a734ce4 ; symbol stub for: -[_uihostedtextservicesession dismisstextserviceanimated:] 0x3a4d5256: add sp, #4 0x3a4d5258: pop {r7, pc} 0x3a4d525a: nop
instances of view controller , mailcontroller printed on console printing description of viewcontroller: printing description of picker: (mfmailcomposeviewcontroller *) picker =