标签: landscape-portrait

iOS仅肖像应用程序从横向UIWebview youtube返回

我正在创建一个iOS application,我遇到了以下问题:

该项目设置为portrait模式应用程序.我有一个UIWebview,它加载一个带有youtube视频的网页.单击视频时,它将从中开始youtube player.当视频更改为landscape模式并单击"完成"时,它将返回UIWebview显示的状态landscape.

NSNotification视频完成后我确实收到了一个但是我无法强制portrait模式.

这应该是不可能的,我如何允许youtube进入landscape但强制应用程序保持portrait模式?或者还有另一种解决方法吗?

编辑:

在与Apple联系之后,它被证明是一个错误并被报道.

youtube uiwebview ios landscape-portrait

5
推荐指数
1
解决办法
1426
查看次数

我可以使用jquery确定设备是处于纵向还是横向模式?

我想有条件地改变用户在我要创建的照片库网站上看到的内容,具体取决于用于查看网站的设备是纵向/垂直还是横向/水平模式/方向.这可能吗?

javascript jquery screen-orientation jquery-mobile landscape-portrait

5
推荐指数
1
解决办法
1万
查看次数

将autocompletetextview结果显示为键盘上方的建议

我有一个autocompletetextview,它工作得很好,但我想将结果显示为键盘上方的建议.默认情况下,在横向模式下执行此操作,但在纵向模式下不执行此操作.有没有办法可以强制它在肖像中做同样的事情?

肖像模式的图片

景观模式的图片

keyboard android autocompletetextview landscape-portrait

5
推荐指数
1
解决办法
1536
查看次数

支持iPhone上的纵向方向的通用应用程序和iPad上的横向+纵向

我需要我的应用程序兼容iPad和iPhone.它有一个tabbarController作为rootViewController.

在iPad中我需要它在Landscape和Portrait上都可用.在iPhone中虽然我需要rootView是Portrait本身,但我确实有一些viewsControllers,它们在tabbarController上呈现,需要在横向和Portrait中可用(例如用于播放Youtube视频的viewController).所以我按如下方式锁定tabbarController的旋转(在UITabbarController子类中).

# pragma mark - UIRotation Methods

- (BOOL)shouldAutorotate{
    return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
}

- (NSUInteger)supportedInterfaceOrientations{
    return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) ? UIInterfaceOrientationMaskAll : UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)

我打算做的是通过锁定rootviewController(tabbarController)的旋转,我锁定tabbarController中的所有VC(仅在iPhone上),并且tabbarController顶部显示的视图可以根据设备方向旋转.

问题

一切都按预期工作,直到应用程序在iPhone中的风景中启动.在横向模式下启动时,应用程序默认为横向并以横向模式启动应用程序,这不是预期的.即使设备方向为横向,它也应在纵向模式下启动.由于我关闭iPhone的自动旋转,应用程序继续在横向本身导致错误.我尝试使用此方法强制应用程序在应用程序中以纵向方式启动:didFinishLaunchingWithOptions:

#pragma mark - Rotation Lock (iPhone)

- (void)configurePortraitOnlyIfDeviceIsiPhone{
    if ((UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone))
        [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
}
Run Code Online (Sandbox Code Playgroud)

问题仍然存在.我已经允许在info.plist上为iPad和iPhone提供SupportInterfaceOrientaions键的所有方向选项,因为我需要应用程序才能在iPhone中使用,即使只有几个viewControllers.如果我可以以某种方式强制该应用程序以纵向方向启动,即使设备方向是横向,也可以解决该问题.如果错误,请纠正我,如果没有,任何帮助使应用程序以纵向模式启动将不胜感激.

我已经在这里这里经历过这个问题,但是还没有让它工作.

谢谢

objective-c rotation uitabbarcontroller ios landscape-portrait

5
推荐指数
1
解决办法
1122
查看次数

如何在应用程序部署信息纵向锁定时手动设置设备方向?

我不希望我的应用程序被美化,并始终是porttrait.So我使我的应用程序部署信息只设置肖像.但是当我需要在我的应用程序中显示任何图像或视频时,我需要横向模式以便更好地显示.

我可以通过检测设备方向的变化

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(orientationChanged:)
 name:UIDeviceOrientationDidChangeNotification
 object:[UIDevice currentDevice]];

- (void) orientationChanged:(NSNotification *)note
{
UIDevice * device = note.object;
switch(device.orientation)
{
    case UIDeviceOrientationPortrait:
        /*  */
        break;

    case UIDeviceOrientationPortraitUpsideDown:
        /*  */
        break;
    case UIDeviceOrientationLandscapeLeft:
       /*  */
       break;

    case UIDeviceOrientationLandscapeRight:
       /*  */
       break;
    default:
        break;
};
}
Run Code Online (Sandbox Code Playgroud)

但是,即使应用程序部署信息纵向被锁定,如何手动更改设备方向?

不起作用

NSNumber *value=[NSNumber numberWithInt: UIDeviceOrientationLandscapeLeft];
[[UIDevice currentDevice] setValue:value forKey:@"orientation"]; 
Run Code Online (Sandbox Code Playgroud)

iphone portrait ios landscape-portrait uideviceorientation

5
推荐指数
2
解决办法
9832
查看次数

更改底部工作表在横向中的位置:"边工作表"

这是这里提出的问题的扩展:

如何让bottomSheet从顶部打开?

Android"Top Sheet"相当于"Bottom Sheet"?

当然,"Bottom Sheet"之所以被称为是因为你可以从底部滑动它.

我在我的设计中发现,这在肖像模式下非常有效(图1和图2),但在横向模式下,我想更好地利用(更多可见性)"主要区域"(图3).出于这个原因,我希望有一个"侧板",有点像导航抽屉(图4).

在此输入图像描述

直到现在我无法找到解决方案或替代方案,欢迎任何帮助!


下面是一个基本代码,用于演示横向模式中的问题

主要活动

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}}
Run Code Online (Sandbox Code Playgroud)

activity_main.xml中

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/container_main"
    android:orientation="vertical">

<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <!-- Main Content -->
    <include layout="@layout/content_main"
        />

    <!-- Bottom Sheet Content -->
    <include layout="@layout/content_bottom_sheet"
        />

</android.support.design.widget.CoordinatorLayout>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

content_main.xml

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:weightSum="2"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:showIn="@layout/activity_main">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="0.6">
    </LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

content_bottom_sheet.xml

    <?xml …
Run Code Online (Sandbox Code Playgroud)

android landscape-portrait bottom-sheet

5
推荐指数
1
解决办法
1062
查看次数

如何更改以编程方式创建的设备方向上的 UIView 子类的框架?

我有一个UIView以编程方式创建的子类。

我的应用程序中有纵向和横向模式,使用自动布局。

最初UIView使用 设定框架initWithFrame,但当方向更改为横向时, 的CGRectUIView停留在纵向模式。

如何提醒子UIView类更改CGRect设备方向?

这是我的初始框架设置代码UIView

- (id)initWithFrame:(CGRect)frame videoUrl:(NSURL *)videoUrl{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        _frame_width = frame.size.width;
        
        int thumbWidth = ceil(frame.size.width*0.05);
        
        _bgView = [[UIControl alloc] initWithFrame:CGRectMake(thumbWidth-BG_VIEW_BORDERS_SIZE, 0, frame.size.width-(thumbWidth*2)+BG_VIEW_BORDERS_SIZE*2, frame.size.height)];
        _bgView.layer.borderColor = [UIColor grayColor].CGColor;
        _bgView.layer.borderWidth = BG_VIEW_BORDERS_SIZE;
        [self addSubview:_bgView];
    }
}
Run Code Online (Sandbox Code Playgroud)

objective-c uiview ios landscape-portrait autolayout

5
推荐指数
1
解决办法
859
查看次数

iOS上单一页面的Flutter设备方向

我想以横向模式在Flutter应用程序中显示单个页面。其他所有屏幕均应以纵向模式显示。

我找到了以下代码片段:

在我的main.dart中

SystemChrome.setPreferredOrientations([
    DeviceOrientation.portraitUp,
    DeviceOrientation.portraitDown,
  ]).then((_) {
    runApp(new IHGApp());
  });
Run Code Online (Sandbox Code Playgroud)

这将以纵向模式启动该应用程序。所以我有要在横向模式下显示的屏幕,这是我在那里使用的代码:

@override
  void initState() {
    super.initState();
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.landscapeRight,
      DeviceOrientation.landscapeLeft,
    ]);
  }


  @override
  void dispose() {
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.portraitUp,
      DeviceOrientation.portraitDown,
    ]);
    super.dispose();
  }
Run Code Online (Sandbox Code Playgroud)

这适用于Android。

在iOS上,似乎无法对单个页面强制使用横向模式。

https://github.com/flutter/flutter/issues/13238

在本文中,我找到了此问题的问题。鲁rod的提到了如何解决这个问题。

“我解决了创建一个小型平台通道的问题,该通道调用此代码以在调用setPreferredOrientations之前立即切换到肖像:”

[[UIDevice currentDevice] setValue:@(UIInterfaceOrientationPortrait) forKey:@"orientation"];
Run Code Online (Sandbox Code Playgroud)

和对应的代码切换到风景

[[UIDevice currentDevice] setValue:@(UIInterfaceOrientationLandscapeLeft) forKey:@"orientation"];
Run Code Online (Sandbox Code Playgroud)

如何在我的应用程序中实现呢?

landscape ios landscape-portrait flutter

5
推荐指数
1
解决办法
585
查看次数

Android - 使用 Renderscript 和 Camera2 API 处理相机数据

下面我想展示我的自定义相机应用程序代码的片段。我的目标是对传入的视频帧应用过滤器并输出它们。为此,我使用 Renderscript 和 Camera2。

这是我的 MainActivity.java (因为它有点长,我删除了处理获取相机权限的方法):

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "MainActivity";
    private static final int REQUEST_CAMERA_PERMISSION_RESULT = 0;

    private TextureView mTextureView;
    private Button mButton;
    private CameraDevice mCameraDevice;
    private String mCameraId;
    private HandlerThread mBackgroundHandlerThread;
    private Handler mBackgroundHandler;
    private Size mPreviewSize;
    private CaptureRequest.Builder mCaptureRequestBuilder;
    private RsSurfaceRenderer mRenderer;
    private Surface mPreviewSurface;
    private Surface mProcessingNormalSurface;
    private RsCameraPreviewRenderer cameraPreviewRenderer;
    private RenderScript rs;
    private List<Surface> mSurfaces;

    private Toast rendererNameToast;
    private String rendererName;

    private int currentRendererIndex = 0; …
Run Code Online (Sandbox Code Playgroud)

java android landscape-portrait android-camera2

5
推荐指数
1
解决办法
976
查看次数

使用 RenderScript 为纵向模式旋转 YUV 图像数据

对于视频图像处理项目,我必须旋转传入的 YUV 图像数据,以便数据不是水平显示而是垂直显示。我使用了这个项目,它让我深入了解了如何将 YUV 图像数据转换为 ARGB 以实时处理它们。该项目的唯一缺点是它仅在景观中。没有纵向模式选项(我不知道为什么 Google 的人提供了一个仅处理横向的示例示例)。我想改变这一点。

因此,我决定使用自定义的 YUV 转 RGB 脚本来旋转数据,使其以纵向模式显示。以下 GIF 演示了应用程序如何在我应用任何旋转之前显示数据。

在此处输入图片说明

你必须知道,在 Android 中,即使设备处于纵向模式,YUV 图像数据也会以横向呈现(我在开始这个项目之前不知道。同样,我不明白为什么没有可用的方法可用于通过一次调用来旋转帧)。这意味着即使设备处于纵向模式,起点也在左下角。但是在纵向模式下,每一帧的起点应该在左上角。我对字段使用矩阵表示法(例如 (0,0)、(0,1) 等)。注意:我从这里拿了草图: 在此处输入图片说明

要旋转横向框架,我们必须重新组织字段。这是我对草图(见上文)所做的映射,它显示了yuv_420横向模式下的单个帧。映射应将框架旋转 90 度:

first column starting from the bottom-left corner and going upwards:
(0,0) -> (0,5)       // (0,0) should be at (0,5)
(0,1) -> (1,5)       // (0,1) should be at (1,5)
(0,2) -> (2,5)       // and so on ..
(0,3) -> (3,5)
(0,4) -> (4,5)
(0,5) -> (5,5)

2nd column starting at …
Run Code Online (Sandbox Code Playgroud)

android yuv renderscript landscape-portrait android-camera2

5
推荐指数
1
解决办法
727
查看次数