开发者

MFMailComposeViewController forces Portrait Orientation on iPad

开发者 https://www.devze.com 2023-02-05 10:09 出处:网络
I am using MFMailComposeViewController for in app email and it works fine in Portrait mode. But when my app which supports both orientation is in landscape mode,

I am using MFMailComposeViewController for in app email and it works fine in Portrait mode. But when my app which supports both orientation is in landscape mode, using [self presentModalViewController:mailVC animated:YES];

forces my entire app into the portrait mode which I don't want.

I have tried many things from overriding MFMailComposeViewController shouldAutorotateToInterfaceOrientation: methods, resigni开发者_开发百科ng the first responder and so on without much luck.

How can I get MFMailComposeViewController work in Landscape on iPad ?


I had the same problem and tried overriding, that's didn't help me.

Try to send "presentModalViewController:" to rootViewController of your application window (in AppDelegate).

I think that's works for me because MFMailComposeViewController can't force rootViewController orientation, but can force orientation of viewControllers that was pushed by rootViewController's navigationController.

You need something like this:

    [((AppDelegate *)[UIApplication sharedApplication]).window.rootViewController presentViewController:mailVC animated:YES completion:nil];


Try overriding the auto rotate function:

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

Alternatively, present the MFMailComposeViewController from the UIViewController which manages rotation within your app.

0

精彩评论

暂无评论...
验证码 换一张
取 消