【问题标题】:IOS - How to force the view to landscapeIOS - 如何强制视图横向
【发布时间】:2012-06-14 16:52:46
【问题描述】:

我想强制我的视图去横向,就在我调用一个方法时。

当我的方法运行时,我调用:

[self shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)UIInterfaceOrientationLandscapeRight];

自动旋转的方法

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}

问题是视图不会强制旋转。可以在模拟器上测试,还是只在真机上运行?

【问题讨论】:

    标签: ios uiview autorotate


    【解决方案1】:
    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:YES];
    

    【讨论】:

    • 我有一个问题。我在里面创建的视图没有设置为横向 :S 现在它应该有 480 宽和 320 高,对吧?但它没有:S
    • 听起来你需要创建一个相对大小的视图。因此,不要使用initWithFrame:CGRectMake(0, 0, 320, 480)] 创建视图,而是尝试类似initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height])
    猜你喜欢
    • 2013-08-26
    • 1970-01-01
    • 1970-01-01
    • 2013-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-12
    相关资源
    最近更新 更多