【问题标题】:Iphone landscape and portrait issueiPhone横向和纵向问题
【发布时间】:2012-04-19 04:56:59
【问题描述】:

我正在开发一个具有启动画面和主屏幕的应用程序。我的应用程序是横向和纵向模式应用程序。 当我的应用程序启动并且我处于横向模式时,我的主屏幕会显示纵向模式几毫秒,然后进入横向模式。我希望它应该直接以横向模式显示视图。

谢谢

【问题讨论】:

标签: iphone


【解决方案1】:

我通常启用通知:

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

在我的控制器上我放了:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{      
    [self configureOrientation:toInterfaceOrientation];
}

- (void)configureOrientation:(UIInterfaceOrientation)orientation
{  

    if(UIDeviceOrientationIsValidInterfaceOrientation(orientation)){

        if(UIInterfaceOrientationIsLandscape(orientation)){
            [self configureLandscapelView];
        }else if(UIInterfaceOrientationIsPortrait(orientation)){
            [self configurePortraitlView];
        }
    } 
}

您还可以从 UIViewController 本身获取方向:

UIInterfaceOrientation orientation = [self interfaceOrientation];

或者从状态栏:

[UIApplication sharedApplication] statusBarOrientation]

【讨论】:

    猜你喜欢
    • 2017-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-11
    • 1970-01-01
    • 1970-01-01
    • 2012-01-08
    • 1970-01-01
    相关资源
    最近更新 更多