问题标签 [uideviceorientation]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
143 浏览

objective-c - 应用程序进入前台状态时的设备/界面方向问题

我有UIViewControllerUINavigationViewController. 这些 VC 必须仅处于纵向模式,但ModalViewControllers附加到UIViewControllers必须处于纵向和横向模式。

所以我在我的项目构建文件中这样做了:

在此处输入图像描述

然后我UINavigationViewController用这个分类:

一切都很好,有史以来最好的。正是我想要的。

但是让我们想象一下,我在一个由UIViewControllers管理UINavigationViewController的应用程序进入后台,我做其他事情。现在我处于横向模式(非常重要!),我将应用程序置于前台(通常通过点击图标)。

一切都还好,正是我想要的。VC 以纵向模式显示,但如果我想调高或调低音量,会发生这种情况:

在此处输入图像描述

当然,如果我从部署信息中取消选择横向模式,问题就不会出现,但是我失去了让我的模态成为横向的能力。

我很感激任何帮助。

0 投票
0 回答
475 浏览

ios - iOS8 Device appears stuck in portrait, but rendering landscape

This is a strange issue that may be related to all the orientation issues I'm seeing in iOS8.

I have a universal app. The iPad version supports only landscape and the iPhone version supports only portrait.

When a user opens the iPad version, it opens in landscape mode, which is expected. However, every control on the right side of the view is unresponsive to user touch events. The affected area is 256 wide, and the area on the left that 'works' is 768 wide (portrait width). Therefore, even though the app opens in landscape, the app thinks it's in portrait. Since the phone version only supports portrait, the issue doesn't reveal itself there, though I believe the issue is not device specific, however, the issue only affects devices running iOS8.

The app was originally developed for iOS4 and has gone through several iterations since. However, much of the original code and nibs are still in use. Other orientation issues have shown up with iOS8 and could be related, or not, who knows?

Since the app was originally designed for iOS4, storyboards were not used, and still aren't. I have checked some things: made sure all nibs have 'Auto resize subviews' checked, and made sure that only landscape orientations existed in the app plist (verified in XML). Here is a code snippet from AppDelegate didFinishLaunchingWithOptions:

enter image description here

In the image, I'm showing both portrait and landscape sizes. As I mentioned earlier, the view controller renders and looks as it should in landscape, but anything in the red area of the image is unresponsive to user taps.

Perhaps I've looked at this issue too long and hopefully somebody has some insight on why this is happening. Anyone? Thanks!

0 投票
0 回答
55 浏览

xcode - Xcode 6.1 是否会成为代码错误的原因

我使用了一个未弃用的设备方向代码,它适用于所有 iOS 7 模拟器和设备。对于 iOS 8,它可以在 iPad 2、iPhone 4s、iPhone 5s、iPhone 5 上运行。但是,在 iOS 8 上,它不能在 iPad Air、iPad Retina、iPhone 6+、iPhone 6 上运行。

Xcode 6.1 是否可以成为某些代码不起作用的原因,然后该代码可以在 Xcode 6.2 上运行?(有人告诉我代码适用于 Xcode 6.2)

0 投票
0 回答
1234 浏览

ios - 当父视图控制器配置为仅纵向时,以横向呈现 UIAlertController

在我的应用程序中,有一个videoViewController仅为纵向配置的。

也就是说,当用户将设备从纵向旋转到横向时,实时预览(位于videoViewController视图的层次结构中)不会随设备旋转(如 Apple 相机应用程序)。当设备处于videoViewController横向UIAlertController模式时,设备上的实例UIAlertController处于纵向。如何确保UIAlertController按照设备方向呈现?任何输入表示赞赏。

在此处输入图像描述

此外,如果我使用UIAlertView代替UIAlertController, 的实例UIAlertView将相应地旋转。因为UIAlertView在 iOS 8.0 中已弃用,我不想使用它。

0 投票
0 回答
466 浏览

objective-c - iOS8:应用程序在后台时的 UIDeviceOrientationDidChangeNotification

我正在使用以下代码来获取设备方向更改通知。

我的应用程序也在后台运行。

  • 当应用程序在前台运行时,通知工作正常。
  • 如果应用程序处于前台并且设备被锁定,则[[UIDevice currentDevice] orientation]始终返回纵向方向,并且在锁定之前会抛出方向更改通知。
  • 但是当应用程序进入后台时,通知就会停止。之后[[UIDevice currentDevice] orientation]将始终返回它最后在活动状态下测量的方向。

有人可以告诉我为什么当我的应用程序进入仍在使用设备的后台状态(被其他应用程序)时通知会停止吗?我正在收集所有方向更改事件,因此我需要设备在应用程序处于前台或后台时向我发送事件。

0 投票
1 回答
391 浏览

ios - 使用模态序列旋转时崩溃

我有像这样链接的视图控制器 1、2 和 3,2 和 3 呈现有模态序列:在此处输入图像描述

当用户处于横向模式一段时间(时间不一致),展开到父视图,然后将手机旋转回纵向时,应用程序崩溃并出现以下象征性的崩溃报告:

3 展开为 2:

由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[NSConcreteMutableData rotatesOnDeviceRotation]:无法识别的选择器已发送到实例 0x19360600”

2 展开为 1:

应用程序因信号 SIGSEGV 而崩溃

我从 Appsee 获得这些报告,因为该应用程序现在处于 beta 测试阶段,而且我似乎无法在我自己的设备上重新创建错误,所以我依赖于在更新之前知道错误是什么。

似乎应用程序“忘记”了它所在的视图,并且不知道要旋转到什么。如果您有任何想法或过去经历过类似的事情,我将不胜感激。

更新 1:

v2/ShinobiCharts.framework/Headers/SChartBandSeries.h:42:57:属性“orientation”的属性“readonly”限制从“SChartSeries”继承的属性的“readwrite”属性

0 投票
1 回答
644 浏览

ios - UIViewController animations wait until animation complete

I'm using this observer: UIDeviceOrientationDidChangeNotification to detect when user is changing the device orientation. When the orientation changed to landscape I present a new UIViewController or dismiss this UIViewController when he changes it back to portrait.

My problem starts when the user start rotating the device number of times and fast, then the application goes crazy until I get this error:

Warning: Attempt to present on whose view is not in the window hierarchy!`.

What is the best possible way to wait until the animation is over and then change the rotation?

This is what I'm using on the Presenting view controller:

This is what I'm using on the Presented view controller:

0 投票
4 回答
11161 浏览

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

我不希望我的应用程序被美化并且始终是纵向的。所以我将我的应用程序部署信息设置为仅设置纵向。但是当我需要在我的应用中显示任何图像或视频时,我需要横向模式才能更好地显示。

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

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

不起作用

0 投票
2 回答
244 浏览

ios - 在导航栏中返回时,在视图上锁定设备方向失败

我有一个在 NavigationController 中嵌入了几个 VC 的应用程序。

我需要将所有 VC 锁定为纵向,并且只有一个锁定在纵向和横向。

我尝试了不同的方法,这个方法对我有用:

然后我像这样修改每个 ViewController:

当我打开应用程序并从一个 VC 转到另一个时,一切都很好。应该只有肖像的视图只有肖像。然后我打开未修改的视图并按预期更改 interfaceOrientation。

但是,假设我将最后一个未修改的视图保留在 Landscape 中,然后按 NavBar 中的后退按钮并转到上一个控制器(已修改为仅纵向)。VC 的布局显示为横向。

如果我一直按下返回按钮,所有其他 VC 的行为就像他们从未被告知只是肖像一样。

我使用了这篇文章Korey Hinton,锁屏旋转

0 投票
0 回答
256 浏览

ios - 自定义叠加 UIImagePickerController 横向模式问题

我有一个UIImagePickerController自定义叠加层。当我在 中以横向打开相机时 iPhone,相机视图无法正确显示。我不希望在横向模式下的相机视图。我希望仅在纵向模式下打开相机视图。

在此处输入图像描述

有人可以帮我解决这个问题吗?提前致谢。