【问题标题】:How to launch landscape view from portrait in iphone?如何在iphone中从纵向启动横向视图?
【发布时间】:2011-12-27 01:03:06
【问题描述】:

我是 iPhone 开发人员的新手,我在 Iphone 中有一个登录屏幕,当我运行时,它仅显示为半屏,然后我更改了它以横向模式显示登录屏幕的方向,但我想要在启动应用程序时它以纵向模式以横向模式显示,并且导航到另一个屏幕也以纵向模式以横向模式显示,如何?请任何人帮助我

 - (BOOL)shouldAutorotateToInterfaceOrientation:()
 {
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if (orientation == UIDeviceOrientationLandscapeLeft ||
         orientation == UIDeviceOrientationLandscapeRight )
{
    return YES;
}  
else if (orientation == UIDeviceOrientationPortrait ||orientation ==    UIDeviceOrientationPortraitUpsideDown)
{ 
    return NO;
}
 }

使用这些代码在纵向模式下无法在横向模式下工作,但我改变了它的工作方向。

【问题讨论】:

  • 嗨,我的问题是如何以纵向启动横向视图?感谢您的回复。

标签: iphone


【解决方案1】:
-(void) viewWillAppear:(BOOL)animated{
    UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];

    [self willAnimateRotationToInterfaceOrientation:orientation duration:0];


}

-(void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    if(toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown )
    {
    set the view for potrait
    }
    else if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight )
    {
    set the view for landscape
    }


}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Overriden to allow any orientation.
    return YES;
} 

希望对你有所帮助。

【讨论】:

    【解决方案2】:

    这是什么意思:“纵向风景”???你有这个或那个,不能同时拥有(除非你有 iPhone ;P)

    在 plist 文件中,您可以确定在启动应用程序时将启动哪种模式 :) “初始界面方向”具有四个方向中的每一个方向的值。设置这个东西的最快方法。虽然稍后在应用程序中管理何时旋转,你应该使用

    -(BOOL)shouldAutorotateToInterfaceOrientation:

    希望这会有所帮助:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-12-30
      • 2018-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多