ImageView保持侧面放置

时间:2012-11-28 20:11:03

标签: ios xcode uiimageview rotation

这是我的问题。我的应用程序从横向模式开始,看起来像这样

enter image description here

我有一些门的图像看起来像:

enter image description here

enter image description here

在AppDelegate didFinishLaunchingWithOptions中,我添加了以下代码,目的是将两个门图像放在与启动图像相同的位置,然后设置动画以显示门的开启。

{
 myImageWalk = [[UIImageView alloc] initWithFrame:CGRectMake(272,0, 286, 748)];
        myImageWalk.image = [UIImage imageNamed:@"leftdoorlandscape.png"];
        [window addSubview:myImageWalk];
        [window bringSubviewToFront:myImageWalk];
        myImageWalk2 = [[UIImageView alloc] initWithFrame:CGRectMake(512,0, 286, 748)];
        myImageWalk2.image = [UIImage imageNamed:@"rightdoorlandscape.png"];
        [window addSubview:myImageWalk2];
        [window bringSubviewToFront:myImageWalk2];
        [self doAnimate:CGRectMake(-286, 20, self.myImageWalk.frame.size.width, self.myImageWalk.frame.size.height)];
        [self doAnimate1:CGRectMake(748, 20, self.myImageWalk2.frame.size.width, self.myImageWalk2.frame.size.height)];
}

唯一的问题是结果是:

enter image description here

为什么图像直线上下,它显示在侧面?

1 个答案:

答案 0 :(得分:1)

您需要将其添加到应用程序的rootViewController上,而不是添加不会处理自动旋转的窗口。这也应该自动处理方向。