【问题标题】:Computing UIVIews new width before rotation旋转前计算 UIVIews 新宽度
【发布时间】:2013-04-17 17:52:22
【问题描述】:

我想知道我的UIViewControllers 视图在旋转更改后将具有的新宽度,但我需要此信息已经在

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

方法,所以我无法访问 frame 或 bounds 属性。

我尝试使用图层属性presentationLayermodelLayer,但没有找到正确的解决方案。

如果有人知道解决方案或可以提供一些思考,那就太好了。

【问题讨论】:

    标签: ios uiview width uiinterfaceorientation


    【解决方案1】:

    我发现了问题!

    我使用的方法被提前调用:

    - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
    

    我知道使用这个:

    - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
    {
        CGRect frame = [self.view.window convertRect:self.view.frame fromView:self.view];
        float newWidth = frame.size.width;
    
        // Doing my animation stuff...
    }
    

    这使我可以拥有正确的新宽度并正确地为我的视图设置动画。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-18
      • 2015-04-18
      • 1970-01-01
      • 2015-08-23
      相关资源
      最近更新 更多