繁体   English   中英

如何从iPhone中的肖像启动横向视图?

[英]How to launch landscape view from portrait in iphone?

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

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

使用这些代码无法在人像的横向模式下工作,但是我更改了它将起作用的方向。

-(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;
} 

希望对您有帮助。

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

在plist文件中,您可以确定应在启动应用程序时启动哪种模式:)“初始界面方向”,其中包含四个方向的值。 设置此事物的最快方法。 尽管以后要在应用中管理是否旋转时,您应该使用

-(BOOL)shouldAutorotateToInterfaceOrientation:

希望这可以帮助 :)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM