我不確定是否正確理解MFMailComposeViewController
。我期待有一個現有視圖的視圖控制器顯示在我的屏幕上。我可以看到FTViewController的視圖。但郵件作曲家從不出現。MFMailComposeViewController顯示空視圖
我已將原始問題簡化爲最低限度。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
FTViewController *vc = [[FTViewController alloc]init];
self.window.rootViewController = vc;
..
}
在FTViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
FTTest *test = [[FTTest alloc] init];
[test testmeup];
}
FTTest:
#import <MessageUI/MessageUI.h>
@interface FTTest : UIViewController <MFMailComposeViewControllerDelegate>
@implementation FTTest
- (void)testmeup
{
BOOL ok = [MFMailComposeViewController canSendMail];
if (!ok)
return;
MFMailComposeViewController* vc = [MFMailComposeViewController new];
vc.mailComposeDelegate = self;
[self presentViewController:vc animated:YES completion:nil];
}
嘗試檢查您是否可以在呈現視圖控制器之前發送郵件(它可能未配置)。你也可以用它作爲調試來告訴你這是否是問題。 [canSendMail](https://developer.apple.com/library/ios/documentation/MessageUI/Reference/MFMailComposeViewController_class/Reference/Reference.html#//apple_ref/occ/clm/MFMailComposeViewController/canSendMail) – hukir
是否有任何電子郵件帳戶在你的郵件? – chancyWu