2013-04-24 93 views
1

之前新的宽度我想知道新的宽度我UIViewControllers视图将有一个旋转的变化后,但我已经需要这些信息在计算UIVIews旋转

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

方法,所以我不能访问框架或边界属性。

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

如果有人知道解决方案或者可以提供一些思路,那将会很棒。

回答

0

我发现问题了!

我用的方法,称为早期:

- (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... 
} 

这让我有正确的新宽度和正确的动画效果我的看法。