我正在为我的程序编写自动化测试,并希望自动化设备方向......我使用下面的代码来设置设备的方向,
UIATarget.localTarget().setDeviceOrientation(UIA_DEVICE_ORIENTATION_LANDSCAPERIGHT);
Run Code Online (Sandbox Code Playgroud)
但我也希望获得该设备的当前方向.我找不到任何getDeviceOrientation()方法来获取方向.
我想知道如何根据JAVA中的设备Orientation改变我的LinearLayout方向,我发现如何通过XML方式进行布局和布局 - 但是我没有找到如何通过java方式做到这一点.
非常感谢你.
android android-layout device-orientation android-orientation
有没有办法改变约束?如果设备处于横向模式,我想更改按钮的高度,centerX和centerY.
这不是一个重复的问题.尚未提供最终工作解决方案.在我接受答案或找到并提供我自己的解决方案之前,请不要关闭此问题.谢谢!
================================================== ================使用Xcode 4.5.1,我有一个标签栏应用程序,里面有5个标签.每个选项卡都包含一个UINavigationController.因此,整个应用程序需要在纵向模式下查看,除了一个唯一的ViewController - 一个"模态"VC,它以全屏模式打开,并且打算在横向模式下查看.
这在iOS5中运行得非常好 - 我只是在一个特定的ViewController中使用了以下代码:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
Run Code Online (Sandbox Code Playgroud)
但现在应用程序崩溃了,并给出了这个错误:
Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation',
reason: 'preferredInterfaceOrientationForPresentation must return a supported interface orientation!'
Run Code Online (Sandbox Code Playgroud)
有什么建议?