【问题标题】:Subview position issue after UIOrientation (rotation) changeUIOrientation(旋转)更改后的子视图位置问题
【发布时间】:2011-02-27 04:34:57
【问题描述】:

我有一个 viewController 并以编程方式在其中添加了一个子视图。

       secondView.autoresizingMask =  UIViewAutoresizingFlexibleWidth;
       [self.view addSubview:secondView];

我猜当设备旋转时,我的 mainViewController 知道方向改变了,但是 mainViewController 内部的子视图(secondView)不知道这一点,所以我在 willRotateToInterfaceOrientation 中将其框架更改为横向大小。

       secondView.frame = CGRectMake(0, 0, 480 , 260);

这没有设置在正确的位置,它在 NavigationBar 下方 11 px。 为什么从导航栏下方 11 px 开始?

当我们从纵向模式切换到横向模式时导航栏会缩小,因此我的子视图低于 11px。

【问题讨论】:

    标签: iphone height rotation subview navigationbar


    【解决方案1】:

    您应该先更改主视图的大小(我想是self.view)。你试过吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-11
      • 2011-05-18
      • 2015-09-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多