我有一个小巧的手机应用程序在iPhone/Mobile Safari上表现得很奇怪.当页面方向垂直时,页面呈现并且效果很好.当我水平旋转手机时,一些,但并非页面上的所有元素都正确调整大小.一些标题元素将保持几乎相同的大小,可能增加10%,其他标题元素将增加一倍.
有没有人碰到这个?我的第一个想法是,css可以混合使用基于ems和px的大小但是找到每个大小的元素并将它们转换为em并没有改变一件事.
我有一个带有tabbar的应用程序,我想在其中检测界面方向.
我在info.plist中设置了支持的方向.这是我的主要接口声明:
@interface MyAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> {
...
}
Run Code Online (Sandbox Code Playgroud)
这是在MyAppDelegate的实现中:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft)
return NO;
if (interfaceOrientation == UIInterfaceOrientationLandscapeRight)
return YES;
if (interfaceOrientation == UIInterfaceOrientationPortrait)
return YES;
if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
return NO;
}
Run Code Online (Sandbox Code Playgroud)
在我试图检测方向变化的必要视图中,我称之为以下方法:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;
Run Code Online (Sandbox Code Playgroud)
和
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation;
Run Code Online (Sandbox Code Playgroud)
我已经在这些方法中设置了NSLog打印,它们都没有注册任何更改.甚至没有在shouldAutorotateToInterfaceOrientation方法中.
谁能帮帮我吗?我做错了什么?任何帮助将不胜感激.
即时通讯尝试orientation在Android应用程序中锁定屏幕.我使用以下代码锁定屏幕方向时,特定按钮点击火.
// Inside button click
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
if (display.getOrientation() == 1) {
setRequestedOrientation(0);
} else if (display.getOrientation() == 0) {
setRequestedOrientation(1);
} else if (display.getOrientation() == 3) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
}
Run Code Online (Sandbox Code Playgroud)
以上代码适用于横向和纵向屏幕方向,但它不适用于反向横向模式.在这种情况下,我的活动总是将其更改orientation为默认模式.landscape此外,我注意到,当设备处于反向横向模式时,display.getOrientation()始终返回3.
我怎样才能找到这个问题的解决方案?
CheckBox包含以下代码:
CheckBox cb = (CheckBox)findViewById(R.id.freezer);
cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
} else {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);
}
}
});
Run Code Online (Sandbox Code Playgroud)
因此,当我检查它时,屏幕旋转到默认的系统方向(我的平板电脑的风景).
我需要冻结CURRENT方向.如果您将设备设置为纵向和切换CheckBox,则必须插入设备旋转,直到取消选中CheckBox.
Display.getRotation()不是解决方案,因为每个设备都有自己的Surface.ROTATION
通过使用setRequestedOrientationin ,我可以以编程方式完美地管理方向变化onCreate.
一切正常,直到我插上HDMI线.在此之后,平板电脑"希望"处于横向模式.所以,当我打开一个活动,它显示在首"风景",然后将其显示之后在"肖像",(因为我打电话的setRequestedOrientation(variable_with_orientation_desired_by_the_user)地方variable=ActivityInfo.SCREEN_ORIENTATION_PORTRAIT在onCreate你可以"看",我的应用程序保持在每一个活动旋转用户打开;
如果我在清单中设置活动的方向,则此问题已部分消失,因为清单中的方向与用户拾取的方向相同.如果它们不同,则会再次开始相同的行为.
我试过这个,但没有成功:
@Override
public void onCreate(final Bundle saved)
{
setRequestedOrientation(ScreenOrientation);
super.onCreate(icicle);
}
Run Code Online (Sandbox Code Playgroud)
那么,有什么方法可以告诉android它在创建活动之前必须创建什么样的方向?(但它不能显而易见)
android orientation screen-orientation android-orientation android-activity
可能重复:
iOS SDK:通过代码UIImageView 将按钮移动到屏幕中心
.缩放和居中到任意矩形.无法在屏幕上确定正确的中心
我正在尝试将UIActivityIndicator集中在UIWebView中(它又是UIScrollView的子视图,左侧还有一个UIToolbar元素 - 尽管左侧工具栏并不总是可见)
之前已经提出过类似的问题,但重点是"动态地"找到中心,即改变方向以及左侧工具栏的存在与否.
什么是最好的方法?有没有比覆盖方法更好的方法shouldAutorotateToInterfaceOrientation呢?
iphone xcode screen-orientation uiactivityindicatorview ipad
有没有办法让Eclipse以横向模式启动Android Emulator(4.1.2)?
我提出的问题是,在启动模拟器后更改方向(使用其中一个键盘快捷键)似乎不会影响主页和其他系统屏幕,尽管它适用于应用程序.
我知道-skin命令行选项,但它已被弃用.
我想我也可以在Android Virtual Device Manager中创建自定义设备,但我宁愿使用Nexus 7预设.
我有一个包含片段的活动,当点击该片段上的某些内容时,我将该片段替换为另一个片段.如果设备在第二个片段中旋转,则会onCreate调用该活动并再次重新创建第一个片段.
如何在设备旋转时停止onCreate被调用?
在我的清单中我有这个
<activity android:name="CalActivity" android:configChanges="orientation|keyboardHidden"/>
Run Code Online (Sandbox Code Playgroud)
我的理解是,将configChanges添加到该活动可防止活动被销毁和重新创建,但onCreate仍会被调用并混乱碎片.
我也尝试过setRetainInstance()插入片段,这也没有帮助
如果设备没有旋转,片段就像它们应该的那样工作,我不想让它成为一个只有一个方向的活动,那就更像是一个黑客而不是实际修复问题
我还可以做些什么?
编辑:
这就是我创建片段的方式
Fragment miniMonthFrag = new MonthByWeekFragment(System.currentTimeMillis(), false);
ft.replace(R.id.cal_frame, miniMonthFrag).commit();
Run Code Online (Sandbox Code Playgroud) 我最近偶然发现了一个问题.
我正在使用这样的嵌套PreferenceScreen:
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceScreen
android:key="pref_name"
android:title="@string/pref_title" >
</PreferenceScreen>
Run Code Online (Sandbox Code Playgroud)
当我的屏幕将焦点放在嵌套首选项屏幕上并且我更改屏幕方向时,嵌套的首选项屏幕将关闭.
我也试过包括:
android:configChanges="orientation|keyboardHidden"
Run Code Online (Sandbox Code Playgroud)
在AndroidManifest.xml中,但没有奏效.
有人有解决方案吗?
编辑可能的解决方案:
我确实找到了解决方案.我以为是这条线:
android:configChanges="keyboardHidden|orientation|screenSize"
Run Code Online (Sandbox Code Playgroud) 我的应用程序使用了几个库.Bassically KYDrawerController.我希望我的应用程序仅使用potraite Orientation,但对于一个ViewControllar我需要landscape和Potrait.
我搜索了互联网上的所有解决方案.每个解决方案都是子类化NavigationControllar和Override ShouldAutoRotate方法.但他们没有为我工作.
灰色的View是KYDrawerControllar视图,它是一个libry用来像Android这样的NavigationDrawer.
我已经为导航控制器创建了一个自定义类,并将其子类化为需要的ViewControllar的Navigation Controllar.
这是守则
class SettingsNavigation: UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()
NSLog("visibleControllar", self.visibleViewController!.debugDescription)
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func shouldAutorotate() -> Bool {
//return self.visibleViewController!.shouldAutorotate()
return false
}
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.Portrait
}
override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
return UIInterfaceOrientation.Portrait
}
/*
// MARK: …Run Code Online (Sandbox Code Playgroud) uinavigationcontroller screen-orientation ios9 xcode7 swift2
android ×6
iphone ×3
orientation ×2
css ×1
emulation ×1
ios9 ×1
ipad ×1
objective-c ×1
preference ×1
swift2 ×1
xcode ×1
xcode7 ×1