【发布时间】:2011-03-14 09:12:16
【问题描述】:
我的视图中有几张图片。在旋转时,我的图像通过 CGAffineTransformTranslate & Rotate 正确放置。
但是,当我在 PortraitUpsidedown 中启动时,会发生我在
中定义的翻译"-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { " 方法。
这种翻译只需要在设备改变方向时发生。如何确保在 Launch 上不会发生这种翻译?
编辑:
在您提示实施 viewWillAppear 方法后仍然遇到问题。
这是我项目的一些代码。
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
image1.transform = CGAffineTransformTranslate( image1.transform, -65.0, 255.0);
image2.transform = CGAffineTransformTranslate( image2.transform, -65.0, 255.0);
}
else {
image1.transform = CGAffineTransformIdentity;
image2.transform = CGAffineTransformIdentity;
}
}
-(void) viewWillAppear:(BOOL)isRotated{
isRotated = FALSE;
}
但是如何实现我定义的那段代码
isRotated = TRUE;
感谢您的帮助!
【问题讨论】:
标签: iphone translation orientation autorotate portrait