ios - 手动设置界面方向

标签 ios ios-4.2 ios4

有什么简单的方法可以手动设置界面的方向吗?我需要将界面设置为纵向,即使设备方向在加载期间可能是横向的。有点想远离 CGAffineTransforms。

最佳答案

我知道一种对我有用的方法(有点 hack,可以在更改为您想要的方向之前显示一个方向)是:

- (void)viewDidAppear:(BOOL)animated 
{
    [super viewDidAppear:animated];

    UIApplication* application = [UIApplication sharedApplication];

    if (application.statusBarOrientation != UIInterfaceOrientationPortrait)
    {
        UIViewController *c = [[UIViewController alloc]init];
        [self presentModalViewController:c animated:NO];
        [self dismissModalViewControllerAnimated:NO];
        [c release];
    }
}

关于ios - 手动设置界面方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7263985/

相关文章:

iphone - iphone 4.3导航栏问题

ios - iPhone降噪功能,我可以禁用\调音吗?

ios - NSUserDefaults 同步不保存

objective-c - UItable 单元格溢出 ios

ipod-touch - 将应用程序部署/调试到 iPod touch 第二代

iphone - iOS - 使用导航 Controller 旋转

iOS - 仅将 UIView 的一部分保存为 PNG

ios - 如何从 iOS 中的 UIPasteboard 中删除项目?

objective-c - 将委托(delegate)分配给我的 PieChartView 时发送到实例的无法识别的选择器

ios - 构建使用CoreImage并在iOS4上禁用其功能的应用