2011-10-11 40 views
0

我的應用程序處於橫向模式,當我打開電子郵件工作表時,即縱向 - 及其確定,鍵盤橫向打開,因此我有縱向電子郵件表和橫向鍵盤。電子郵件鍵盤在橫向?

我該如何解決它,鍵盤將在肖像也? 爲什麼按「取消」時,它不會回到應用程序,什麼都沒有發生?

//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:@"[email protected]"]; 
     [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];  

回答

1

,而不是添加MFMailComposeViewController實例的視圖當前正在使用的視圖,你需要顯示它作爲一個模式視圖控制器。不幸的是,cocos2d(我假設你在你的代碼中使用CCDirector類)不是建立在默認的UIKit顯示之上的。

這意味着您必須找到您的應用程序的根視圖控制器並調用其presentModalViewController:方法。有幾種方法可以做到這一點,例如本博客文章中詳述的方法(由其他人撰寫,但體面的方法):http://indiedevstories.com/2011/06/25/modal-view-controllers-in-cocos2d/

相關問題