我试图使用以下方法冻结方向:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Run Code Online (Sandbox Code Playgroud)
虽然显示屏保持纵向,但仍会重新创建活动.任何想法如何解决这个问题?
如何锁定应用程序的方向,以便在方向更改时不重新创建活动?
你如何使应用程序只支持景观?在xcode 3中,没有肖像模式只是整个事物的风景吗?
我正在创建一个相机应用程序.捕获时的图像显示在网格视图中.现在,代码在除三星设备之外的所有设备上都能正常工作.
我正面临着方向问题.当我以纵向模式拍摄图像时,图像在网格视图中显示时会旋转.我没有保留任何旋转代码.其次,使用EXIF我在网格视图中获得了正确的图像,但是当设备方向改变时,图像再次以旋转的方式旋转.
附加图片:


对不起图像的分辨率.请知道它们是否不正确.将再次上传.我知道SO上有很多这样的帮助.但我想我在某个地方被困住了.
我指的是以下链接:
http://blog.andolasoft.com/2013/06/how-to-show-captured-images-dynamically-in-gridview-layout.html
android screen-orientation android-camera android-camera-intent android-orientation
我有一个UINavigationController作为我在iOS 7和iOS 8上的UIWindow的根视图控制器.从它的一个视图控制器,我提出了一个具有交叉溶解演示风格的全屏模态视图控制器.这个模态视图控制器应该能够旋转到所有方向,并且它工作正常.
问题是当设备以横向方向保持并且模态视图控制器被解除时.呈现模态的视图控制器仅支持纵向方向,并且我已确认UIInterfaceOrientationMaskPortrait返回到-application:supportedInterfaceOrientationsForWindow:.-shouldAutorotate也返回YES.然而,在解除模态之后,呈现视图控制器的方向仍然是风景.在允许模态采取设备方向的同时,如何强制它保持纵向方向?我的代码如下:
应用代表:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
UINavigationController *navigationController = (UINavigationController *)self.deckController.centerController;
NSArray *viewControllers = [navigationController viewControllers];
UIViewController *top = [viewControllers lastObject];
if (top && [top presentedViewController]) {
UIViewController *presented = [top presentedViewController];
if ([presented respondsToSelector:@selector(isDismissing)] && ![(id)presented isDismissing]) {
top = presented;
}
}
return [top supportedInterfaceOrientations];
}
return (UIInterfaceOrientationMaskLandscapeLeft|UIInterfaceOrientationMaskLandscapeRight);
}
Run Code Online (Sandbox Code Playgroud)
呈现视图控制器:
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait;
} …Run Code Online (Sandbox Code Playgroud) 我正在使用viewWillTransitionToSize来检测设备何时旋转到横向.根据目标大小,我可以检测是否前往景观并根据需要调整我的特征......
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
if size.width > size.height {
self.setOverrideTraitCollection(UITraitCollection(horizontalSizeClass: UIUserInterfaceSizeClass.Regular), forChildViewController: viewController)
}
else{
self.setOverrideTraitCollection(nil, forChildViewController: viewController)
}
super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)
}
Run Code Online (Sandbox Code Playgroud)
但是,我希望能够检测我的设备是转换到横向左侧还是横向右侧.这将允许我根据设备的具体方向创建不同的行为或视图.(左还是右).
这可能不使用任何已弃用的函数吗?
我想过使用状态栏方向......
let orientation = UIApplication.sharedApplication().statusBarOrientation;
if( orientation == UIInterfaceOrientation.LandscapeLeft )
{
// Do something
}
else if( orientation == UIInterfaceOrientation.LandscapeRight )
{
// Do something else
}
Run Code Online (Sandbox Code Playgroud)
...但这没有用,因为这似乎给出了"旧的"状态方向.
如何获得特定的目标定位?
在开发Android应用程序时,我发现了两个用于设置屏幕方向的ActivityInfo属性.
具有USER的属性如下:
具有SENSOR的属性如下:
SCREEN_ORIENTATION_USER和SCREEN_ORIENTATION_SENSOR之间有什么区别?
您好我想知道如何在nativescript中设置设备方向.具体来说,我希望我写的应用程序始终保持相同的方向(纵向),以便旋转设备不会导致它进入横向.
我尝试了nativescript-orientation插件和setOrientation.
var orientation = require('nativescript-orientation');
console.log(JSON.stringify(orientation));// outputs JS: {}
orientation.setOrientation("portrait");
Run Code Online (Sandbox Code Playgroud)
但是我收到错误"无法读取属性setOrientation of undefined.tns插件列表显示插件已安装.此外,我尝试删除platforms/android目录并运行tns platform add android相同的结果.
我也尝试将各种组合android:screenOrientation="portrait"放入AndroidManifest.xml但没有成功.
App_resources内部的AndroidManifest.xml看起来像这样
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="__PACKAGE__"
android:versionCode="1"
android:versionName="1.0">
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"/>
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="__APILEVEL__"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:screenOrientation="portrait"
android:name="com.tns.NativeScriptApplication"
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name="com.tns.NativeScriptActivity"
android:label="@string/title_activity_kimera"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="@style/LaunchScreenTheme">
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.tns.ErrorReportActivity"/>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud) 我有一个应用程序,显示大量的文本供用户阅读.
我发现躺下时读书时,即使我的头和屏幕对齐,我仍然对屏幕旋转感到恼火.
我不想将它设置为永久处于纵向模式,所以我认为这将排除设置的方法
android:screenOrientation="portrait"
Run Code Online (Sandbox Code Playgroud)
在清单中.
理想情况下,我想通过首选项页面启用/禁用自动方向更改.
什么是我最好的方法?
我有一个FragmentActivity和一个处理2个碎片的ViewPager.
Run Code Online (Sandbox Code Playgroud)public class MyFragmentActivity extends FragmentActivity{
private Fragment f1; private Fragment f2; private ViewPager myPager; private MyFragmentAdapter mFragmentsAdapter; private static ArrayAdapter<Fragment> mFragmentArray; public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.my_layout); myViewPager = (ViewPager) findViewById(R.id.pager_acciones); mFragmentArray = new ArrayAdapter<Fragment>(getApplicationContext(),android.R.layout.simple_list_item_1); f1 = new Fragment(); f1 = new Fragment(); mFragmentArray.add(f1); mFragmentArray.add(f2); mFragmentsAdapter = new MyFragmentAdapter(getSupportFragmentManager()); myPager.setAdapter(mFragmentsAdapter); myPartidoPager.setCurrentItem(0); } public static class MyFragmentAdapter extends FragmentPagerAdapter { public AccionesFragmentAdapter(FragmentManager fm) { super(fm); } @Override public int getCount() { return mFragmentArray.getCount(); } @Override public Fragment getItem(int position) …
我正在创建一个仅支持纵向模式的应用程序.我不希望风景或人像颠倒.我尝试了一些代码.这允许我锁定纵向模式.
我正在使用navigationcontroller和presentviewcontroller.现在我的问题是:1.如果我将设备颠倒并打开我的应用程序,它会以颠倒模式打开,这是错误的.2.我点击一些按钮,进入presentviewcontroller,返回纵向模式.
我希望所有的navigationcontroller和presentviewcontroller都处于纵向模式
我的代码:
我设置了设备orientarion肖像 Target -> General -> Deployment Info -> Portrait
在我的appdelagate.swift中:
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.Portrait
}
Run Code Online (Sandbox Code Playgroud)
在我的第一个视图控制器.这基本上是导航控制器的孩子
override func shouldAutorotate() -> Bool {
return false
}
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return [UIInterfaceOrientationMask.Portrait ]
}
Run Code Online (Sandbox Code Playgroud)
编辑1:
我也定了 StoryBoard -> ViewController -> Attribute Inspector -> Orientation -> Portrait
编辑2:
android ×6
ios ×4
iphone ×3
orientation ×2
fragment ×1
nativescript ×1
objective-c ×1
preferences ×1
rotation ×1
size-classes ×1
swift ×1