进行界面定向时图像弹跳

问题描述 投票:0回答:2

我的应用程序中正在进行寻呼。每个页面都有图像。在定向过程中,我根据横向和纵向更改框架。但图像正在弹跳。它不应该弹跳并且要平稳设置。

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

我正在更改

中的框架
- (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
”中我正在改变框架。

iphone ios objective-c image uiimageview
2个回答
1
投票

如果您使用的是iOS6,您可以使用[自动布局][1]。原因可能是因为你使用了延迟。如果您使用下面的代码,它可能会起作用。

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

     

0
投票

你在做

iOS6+
吗?如果是,那么我建议您遵循它的
autoLayout
功能。一步步看一遍开始 iOS 6 中的自动布局,你就会明白
autoLayout
的美妙之处。在
autoLayout
中,无需在代码中手动设置框架的位置。

© www.soinside.com 2019 - 2024. All rights reserved.