如何在 cocos2d 中使用 MFMailComposeViewController 以横向模式显示邮件编辑器?
我正在用cocos2d 写一个游戏。我想将 MFMailComposeViewController 添加到场景中。 因此,当我触摸场景中的 CcLabel 时,邮件表就会打开。
@interface EmailScene : CCScene <MFMailComposeViewControllerDelegate>
{
MFMailComposeViewController *picker;
}
-(void)displayComposerSheet;
@end
@implementation EmailScene
- (id) init {
self = [super init];
if (self != nil) {
[self displayComposerSheet];
}
return self;
}
-(void)displayComposerSheet
{
[[CCDirector sharedDirector] pause];
picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
NSArray *toRecipients = [NSArray arrayWithObject:@"[email protected]"];
[picker setToRecipients:toRecipients];
[[[CCDirector sharedDirector] openGLView] addSubview:picker.view];
[[CCDirector sharedDirector] stopAnimation];
}
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
[[CCDirector sharedDirector] resume];
CCScene *Scene = [CCScene node];
CCLayer *Layer = [GameWinScreen node];
[Scene addChild:Layer];
[picker.view removeFromSuperview];
[[CCDirector sharedDirector] startAnimation];
[picker dismissModalViewControllerAnimated:YES];
[[CCDirector sharedDirector] replaceScene:Scene];
}
@end
替代文本 http://www.freeimagehosting.net/uploads/4a77b9ceb9.png
但是,问题是我的游戏处于横向模式。因此,我需要以横向模式显示邮件表。但是,这里邮件表以纵向模式显示。并且键盘以横向模式显示。但是,邮件撰写表处于纵向模式。
我们怎样才能将“从我的iPhone发送”更改为“从我的iPad发送”
谢谢。
I am writing a game in cocos2d. I want to add MFMailComposeViewController to the scene.
So, when I touch a CcLabel in the scene the mail sheet is opened.
@interface EmailScene : CCScene <MFMailComposeViewControllerDelegate>
{
MFMailComposeViewController *picker;
}
-(void)displayComposerSheet;
@end
@implementation EmailScene
- (id) init {
self = [super init];
if (self != nil) {
[self displayComposerSheet];
}
return self;
}
-(void)displayComposerSheet
{
[[CCDirector sharedDirector] pause];
picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
NSArray *toRecipients = [NSArray arrayWithObject:@"[email protected]"];
[picker setToRecipients:toRecipients];
[[[CCDirector sharedDirector] openGLView] addSubview:picker.view];
[[CCDirector sharedDirector] stopAnimation];
}
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
[[CCDirector sharedDirector] resume];
CCScene *Scene = [CCScene node];
CCLayer *Layer = [GameWinScreen node];
[Scene addChild:Layer];
[picker.view removeFromSuperview];
[[CCDirector sharedDirector] startAnimation];
[picker dismissModalViewControllerAnimated:YES];
[[CCDirector sharedDirector] replaceScene:Scene];
}
@end
alt text http://www.freeimagehosting.net/uploads/4a77b9ceb9.png
But, the problem is my game is in landscape mode. So, I need the mail sheet to display in landscape mode. But, here the mail sheet is displayed in portrait mode. And the keyboard is appearing in landscape mode. But, the mail composure sheet is in portrait mode.
And how can we change the "sent from my iPhone" to "Sent From My iPad"
Thank you.
alt text http://www.freeimagehosting.net/uploads/3eb39ea1de.png
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以尝试手动旋转视图...:
You can try to manually rotate view...:
您可以创建自己的从 MFMailComposeViewController 派生的邮件编写器,并且只能覆盖函数 shouldAutorotateToInterfaceorientation。
我没有尝试过,只是给你一个想法。
You can make your own mailcomposer that is derived from MFMailComposeViewController and you can overwrite only the function shouldAutorotateToInterfaceorientation.
I didn't try this, just give you an idea.
谁在管理您的 EmailScene 对象?如果您遵循 MVC 模式,请尝试使用 EmailScene 视图的 viewController 来呈现 MFMailComposeViewController 对象。如果您支持视图控制器中的所有方向,这将起作用。
使用:
而不是将 MFMailComposeViewController 的视图添加为子视图。
编辑:尝试使用根视图控制器呈现 MFMailComposeViewController。
Who is managing your EmailScene object? If you have followed the MVC pattern, try present the MFMailComposeViewController object using the viewController of EmailScene view. This will work provided you have supported all orientations in the view controller.
Use:
Instead of adding the MFMailComposeViewController's view as a subview.
Edit: Try to present the MFMailComposeViewController using the root view controller.