我的应用程序处于横向模式,当我打开电子邮件表时,即纵向 - 并且确定,键盘以横向打开,因此我有纵向电子邮件表和横向键盘
我如何解决它,键盘也将处于纵向? 为什么当按下“取消”时,它不会回到应用程序而没有任何反应?
//send email log-------------------------
NSLog(@"mail");
[[CCDirector sharedDirector] pause];
picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
//Fill in the email as you see fit
NSArray *toRecipients = [NSArray arrayWithObject:@"r@gmail.com"];
[picker setToRecipients:toRecipients];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *dataPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"BetaTest.txt"];
NSData *data = [NSData dataWithContentsOfFile:dataPath];
[picker addAttachmentData:data mimeType:@"text/txt" fileName:@"BetaTest.txt"];
NSString *emailBody = @"test :) ";
[picker setMessageBody:emailBody isHTML:NO];
[picker setSubject:@"hardware test##"];
//display the view
[[[CCDirector sharedDirector] openGLView] addSubview:picker.view];
[[CCDirector sharedDirector] stopAnimation];
答案 0 :(得分:1)
您需要将其显示为模态视图控制器,而不是将MFMailComposeViewController
实例的视图添加到当前活动视图中。不幸的是,cocos2d(我假设您使用的是代码中的CCDirector
类)并不构建在默认的UIKit显示之上。
这意味着您必须找到应用程序的根视图控制器并调用其presentModalViewController:
方法。有几种方法可以做到这一点,例如本博客文章中详述的方法(由其他人编写,但是一种不错的方法):http://indiedevstories.com/2011/06/25/modal-view-controllers-in-cocos2d/