UIView中的方向添加到UIWindow [英] Orientation in a UIView added to a UIWindow

查看:300
本文介绍了UIView中的方向添加到UIWindow的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UIView应该覆盖整个设备(UIWindow)以支持图像放大/缩小效果我正在使用核心动画,其中用户点击UITableViewCell上的按钮并放大相关图像。

I have a UIView which is supposed to cover the whole device (UIWindow) to support an image zoom in/out effect I'm doing using core animation where a user taps a button on a UITableViewCell and I zoom the associated image.

缩放是完美无瑕的,我无法弄清楚的是,即使设备处于横向状态,子视图仍然处于纵向模式。如下图所示:

The zooming is performing flawlessly, what I haven't been able to figure out is why the subview is still in portrait mode even though the device is in landscape. An illustration below:

我确实有一个导航控制器,但这个视图已直接添加到UIWindow。

I do have a navigation controller but this view has been added to the UIWindow directly.

推荐答案

您可以在这里阅读一些可能的原因:

技术Q& A QA1688 - 为什么我的UIViewController不能随设备一起旋转?

You can read about some of the possible causes here:
Technical Q&A QA1688 - Why won't my UIViewController rotate with the device?

在您的情况下,它可能是事实您正在将视图添加为窗口的另一个子视图。只有第一个子视图才能获得旋转事件。您可以做的是将其添加为第一个窗口子视图的子视图。

In your situation its probably the fact that you are adding the view as another subview to the window. Only the first subview gets the rotation events. What you can do is add it as a subview of the first window subview.

UIWindow* window = [UIApplication sharedApplication].keyWindow;
if (!window) 
    window = [[UIApplication sharedApplication].windows objectAtIndex:0];
[[[window subviews] objectAtIndex:0] addSubview:myView];    

这篇关于UIView中的方向添加到UIWindow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆