MFMailComposeViewController in iOS 8

江枫思渺然 提交于 2020-01-05 11:02:22

问题


First, my app worked fine on iOS 7, since iOS 8 i can't send in-app email thru "MFMailComposeViewController". Message window comes up, only shows subject of the mail and closes within seconds. I found this thread here which describes my problem and now tried to implement the answer from "Joe Blow" https://stackoverflow.com/a/25864182/4061869

But im getting some errors, some sematic and parse issues.

Worst thing according to this part of the workaround:

Of course have this in your Prefix file

#define APP ((AppDelegate *)[[UIApplication sharedApplication] delegate])
// it's worth noting that is the delegate, not the "application"

Leads to this error:

Use of undeclared identifier 'AppDelegate'

Anyone knows where the problem can be? I tried different wordings on 'AppDelegate' according to my filename of the appdelegat.h/.m but nothing helps.


回答1:


You can define the app delegate in whichever ViewController you are working in, by using:

AppNameAppDelegate *APP = [[UIApplication sharedApplication]delegate];

To state the obvious, by AppName I mean the name of your application. Make sure to import the AppDelegate.h into your .m file too.

#import "AppNameAppDelegate.h"

For the record, I am also having the same issue with MFMailComposeViewController,and I have tried the method suggested in the post you linked (creating a global mail composer), but it still won't work for me using the iOS 8 simulator. Apparently it works on a physical device running iOS 8, but I personally cannot confirm that just yet.



来源:https://stackoverflow.com/questions/25953103/mfmailcomposeviewcontroller-in-ios-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!