简体   繁体   中英

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). 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).

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];

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:

- (BOOL)shouldAutorotateToInterfaceOrientation

which is returning YES in both landscape modes. This rootVC is firing up ShareVC which has 3 buttons for 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...
I also set orientations in plist to landscape modes. Hope this clarify what I am trying to do :)

Try adding this to the desired ViewController:

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

I don't have a Mac nearby, so there might be error(s).

hope it helps

Problem fixed :) turned out I was calling present/dismiss modalViewController on a childVC not on rootVC itself, here is code snippet:

-(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];
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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