ios - Swift: In-app email freezes for few seconds and throws exception -
i'm trying add together in-app email feature application. found code online when run app, freezes few seconds , throws exception. below code used
@ibaction func sendmail(sender: anyobject) { allow mailcomposeviewcontroller = configuredmailcomposeviewcontroller() if mfmailcomposeviewcontroller.cansendmail() { self.presentviewcontroller(mailcomposeviewcontroller, animated: true, completion: nil) } else { self.showsendmailerroralert() } } func configuredmailcomposeviewcontroller() -> mfmailcomposeviewcontroller { allow mailcomposervc = mfmailcomposeviewcontroller() mailcomposervc.mailcomposedelegate = self mailcomposervc.settorecipients(["someone@somewhere.com"]) mailcomposervc.setsubject("sending in-app e-mail...") mailcomposervc.setmessagebody("body", ishtml: false) homecoming mailcomposervc } func showsendmailerroralert() { allow sendmailerroralert = uialertview(title: "could not send email", message: "your device not send e-mail. please check e-mail configuration , seek again.", delegate: self, cancelbuttontitle: "ok") sendmailerroralert.show() } // mfmailcomposeviewcontrollerdelegate method func mailcomposecontroller(controller: mfmailcomposeviewcontroller!, didfinishwithresult result: mfmailcomposeresult, error: nserror!) { controller.dismissviewcontrolleranimated(true, completion: nil) }
and exception is:
*** assertion failure in -[uikeyboardtaskqueue waituntilalltasksarefinished], /sourcecache/uikit_sim/uikit-3318.16.14/keyboard/uikeyboardtaskqueue.m:374 *** terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: '-[uikeyboardtaskqueue waituntilalltasksarefinished] may called main thread.'
some post suggested need cycle mfmailcomposeviewcontroller after each use. have no thought on how implement that.
ios swift ios8
No comments:
Post a Comment