Iphone 帮助我了解设备定位
在iPad my app中,我有两个视图,第一个视图可以是纵向或横向视图,但第二个视图应该是横向模式。因此,我使用下面的命令强制第二个视图以横向模式显示Iphone 帮助我了解设备定位,iphone,iphone-sdk-3.0,Iphone,Iphone Sdk 3.0,在iPad my app中,我有两个视图,第一个视图可以是纵向或横向视图,但第二个视图应该是横向模式。因此,我使用下面的命令强制第二个视图以横向模式显示 [[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeRight]; 但是,在进入第二个视图后,当我检查设备定向时,它返回“纵向”。但第二个视图始终处于横向模式。但为什么我会走错方向 感谢您提供有关
[[UIApplication sharedApplication] setStatusBarOrientation:
UIInterfaceOrientationLandscapeRight];
但是,在进入第二个视图后,当我检查设备定向时,它返回“纵向”。但第二个视图始终处于横向模式。但为什么我会走错方向
感谢您提供有关设置方向的帮助,UIViewController或类似工具具有可覆盖的功能 具体来说,请查看此项并向下滚动至“shouldAutorotateToInterfaceOrientation:” 强制横向模式的代码应如下所示:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ((interfaceOrientation==UIInterfaceOrientationPortrait)||(interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown))
{
return NO;
}
else if ((interfaceOrientation==UIInterfaceOrientationLandscapeLeft)||(interfaceOrientation==UIInterfaceOrientationLandscapeRight))
{
return YES;
}
else {
return YES;
}
}
此代码应包含在视图控制器对象中,并在启动视图控制器时自动调用。您应该有两个UIViewController,并覆盖shouldAutorotateToInterfaceOrientation方法,以便它们在两种情况下都具有不同的行为