1

iPad 응용 프로그램의 메일 작성자 시트에 다음 코드를 사용하고 있습니다. iPhone 용으로 동일한 코드를 사용했습니다. 그것은 효과가 있었다.
저는 cocos2d를 사용하여 iPad에서 게임을 작성하고 있습니다. 게임은 landScape 모드입니다. EmailScene의 컨트롤은 [picker presentModalViewController : picker animated : YES]에서 중지됩니다. 오류를주지 않습니다. iPad 용 코드를 변경해야합니까?presentModalViewController : picker가 iPad에서 작동하지 않습니다. MFMailComposeViewController

@interface EmailScene : CCScene <MFMailComposeViewControllerDelegate> 
{ 
    MFMailComposeViewController *picker; 
} 

-(void)displayComposerSheet; 

@end 

@implementation EmailScene 

- (id) init { 
    self = [super init]; 
    if (self != nil) { 
     [self displayComposerSheet]; 
    } 
    return self; 
} 

// Displays an email composition interface inside the application. Populates all the Mail fields. 
-(void)displayComposerSheet 
{ 

    [[CCDirector sharedDirector] pause]; 

    picker = [[MFMailComposeViewController alloc] init]; 
    picker.mailComposeDelegate = self; 

    //Fill in the email as you see fit 
    NSArray *toRecipients = [NSArray arrayWithObject:@"[email protected]"]; 
    [picker setToRecipients:toRecipients]; 

    //display the view 
    [[[CCDirector sharedDirector] openGLView] addSubview:picker.view]; 
    [[CCDirector sharedDirector] stopAnimation]; 

//When I commented the following two lines the mail page is opening. 
    //[picker presentModalViewController:picker animated:YES]; 

    //[picker release]; 

} 

그러나 내 게임은 가로 모드이고 메일 시트는 세로 모드로 표시됩니다. 감사합니다.

답변

0

-presentModalViewController:…을 잘못 사용하고 있습니다. 이 메서드는 "picker"가 표시되기 전에 최상위 뷰 컨트롤러에서 호출되어야합니다.

[topmostViewController presentModalViewController:picker animated:YES]; 

(당신은 어느 -openGLView의 서브 뷰으로 picker.view를 추가하지 않아야합니다.)

+0

나는 하나의 뷰 컨트롤러를 가지고 내 인터페이스 클래스 나는 질문했다. 게임은 cocos2d에 있습니다. 내 프로그램에서 최상위의 ViewController는 무엇이 될까요? 감사합니다. –

+0

@srikanth : "topmostViewController"는 표시되는보기 컨트롤러입니다. 귀하의 경우, 그것은 "하나의보기 컨트롤러"입니다. – kennytm

+0

내 게임에는 하나의보기 컨트롤러 만 있습니다. 이전 장면에서 CCLabel을 터치하면 메일 시트가 표시됩니다. 그래서 저는 EmailScene을 뷰 컨트롤러로 사용했습니다. 감사합니다. –

관련 문제