【问题标题】:UITableView orientation error after dismissing a MailComposerView关闭 MailComposerView 后 UITableView 方向错误
【发布时间】:2014-02-04 10:13:21
【问题描述】:

我有一个 UITableView,它是横向的。选择后,用户可以从此表中邮寄任何图像。现在,当我关闭邮件编辑器视图(也是横向右向)发送邮件后,它带我回到桌子,方向变成纵向。但它应该是横向的。我还设置了以下内容以强制在横向的表格视图中,在该表格视图和邮件撰写器视图中:

-(void)viewWillAppear:(BOOL)animated{

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:YES];

}

但它仍然以纵向模式出现。我现在该怎么办?提前感谢您的帮助。

【问题讨论】:

    标签: ios iphone objective-c uitableview


    【解决方案1】:
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
        return UIDeviceOrientationLandscapeRight;
    }
    

    编辑:

    #pragma mark - MFMailComposeViewController Category method
    
    @interface MFMailComposeViewController(FixedOrientation)
    -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation;
    @end
    
    @implementation MFMailComposeViewController(FixedOrientation)
    -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
        return (toInterfaceOrientation==UIInterfaceOrientationLandscapeRight);
    }
    @end
    

    试试这个,这允许你在首选的 InterfaceOrientation 中呈现模态视图控制器。 希望对你有帮助。

    【讨论】:

    • 不工作,兄弟。关闭邮件视图后,表格视图变为纵向。
    猜你喜欢
    • 2012-12-27
    • 1970-01-01
    • 2012-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-18
    • 1970-01-01
    相关资源
    最近更新 更多