1

我的应用程序中有分页。每个页面都有图像。在定向期间,我根据横向和纵向方向更改框架。但图像在弹跳。它不应该弹跳并且想要平稳设置。

请让我们知道我能做什么。

我正在改变框架

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

这是一些代码。

 - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
    {
        if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
        {
            [self performSelector:@selector(setLandscapeOrientationFrame) withObject:nil afterDelay:(duration/2)];
        }
        else
        {
            [self performSelector:@selector(setPortraitOrientationFrame) withObject:nil afterDelay:(duration/2)];
        }

    }

而在“ setPortraitOrientationFrame”和“ setLandscapeOrientationFrame”中,我正在改变框架。

4

2 回答 2

1

如果您使用的是 iOS6,则可以使用autolayout。原因可能是因为你使用了延迟。如果您使用下面的代码,它可能会起作用。

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

     if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
     {
         [self setLandscapeOrientationFrame];
     }
     else
     {
         [self setPortraitOrientationFrame];
     }

}
于 2013-05-03T05:12:56.373 回答
0

你在工作iOS6+吗?如果是,那么我建议您遵循autoLayout它的功能。一步一步地通过iOS 6 中的Beginning Auto Layout ,你就会明白autoLayout. autoLayout无需在代码中手动设置框架的位置。

于 2013-05-03T05:37:01.437 回答