简体   繁体   English

如何在Landscape iPhone应用中运行电子邮件/短信?

[英]How to run email/sms in landscape iPhone app?

I have an iPhone app, which is running only in landscape mode, but recently I wanted to add mail/sms/facebook features (via UIButton actions). 我有一个iPhone应用程序,仅在横向模式下运行,但是最近我想添加邮件/短信/ facebook功能(通过UIButton操作)。 The last one is running smoothly, I launch web browser (itself manages portrait mode), but starting mail or sms composer is driving me mad. 最后一个运行平稳,我启动了网络浏览器(它自己管理人像模式),但是启动邮件或短信作曲家却让我发疯。 I Just want to use this app only in landscape mode, excluding launching mail/sms/fb (browser actually). 我只想仅在横向模式下使用此应用程序,但不包括启动mail / sms / fb(实际上是浏览器)。

I managed to have mail/sms composer in portrait mode when having app screen in landscape, but keyboard appears in landscape too, which is blocking the left/right half of composer - did it with [composer setModalTransitionStyle:UIModalTransitionStyleCrossDissolve]; 当应用程序屏幕横向放置时,我设法使纵向的邮件/短信编辑器处于垂直模式,但是键盘也横向出现,这阻塞了编辑器的左/右一半-使用[composer setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];

either I'm reading bad stuff on this topic or I'm simply blind ;) - either way any help needed, thanks 我是在阅读有关此主题的坏东西,还是我只是盲目;)-无论哪种方式,都需要任何帮助,谢谢

EDIT: 编辑:

I have a root ViewController with overridden: 我有一个覆盖的根ViewController:

- (BOOL)shouldAutorotateToInterfaceOrientation

which is returning YES in both landscape modes. 在两种横向模式下均返回“是”。 This rootVC is firing up ShareVC which has 3 buttons for mail/sms/fb. 这个rootVC启动了ShareVC,它具有3个用于mail / sms / fb的按钮。 I wish to acheive something like firing up web browser, which starts in portrait. 我希望实现启动网页浏览器之类的功能,该功能从纵向开始。 The same with mail & sms, but using modal view controllers and then returning to ShareVC after sending mail/sms... 与邮件和短信相同,但使用模式视图控制器,然后在发送邮件/短信后返回ShareVC ...
I also set orientations in plist to landscape modes. 我还将plist中的方向设置为横向模式。 Hope this clarify what I am trying to do :) 希望这可以澄清我要做什么:)

Try adding this to the desired ViewController: 尝试将其添加到所需的ViewController中:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  return interfaceOrientation==UIInterfaceOrientationLandscapeLeft;
}

I don't have a Mac nearby, so there might be error(s). 我附近没有Mac,因此可能有错误。

hope it helps 希望能帮助到你

Problem fixed :) turned out I was calling present/dismiss modalViewController on a childVC not on rootVC itself, here is code snippet: 解决的问题:)事实证明,我是在childVC而不是rootVC本身上调用present / dismiss modalViewController,这是代码段:

-(IBAction)goMail{
    NSLog(@"gomail...");
    MFMailComposeViewController *picker = [[[MFMailComposeViewController alloc] init] autorelease];
    NSUserDefaults *settings = [NSUserDefaults standardUserDefaults];

    if ([MFMailComposeViewController canSendMail]) {
        picker.mailComposeDelegate = self;
        [picker setSubject:@"Hello iPhone!"];

        // Set up recipients
        NSArray *toRecipients = [NSArray arrayWithObject:@"aa@bb.com"];
        [picker setToRecipients:toRecipients];
        [picker setMessageBody:@"mail content..." isHTML:NO];
        [self.controller presentModalViewController:picker animated:YES];
        //[picker release];
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM