我的应用程序中正在进行寻呼。每个页面都有图像。在定向过程中,我根据横向和纵向更改框架。但图像正在弹跳。它不应该弹跳并且要平稳设置。
请让我们知道我能做什么。
我正在更改
中的框架- (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
”中我正在改变框架。
如果您使用的是iOS6,您可以使用[自动布局][1]。原因可能是因为你使用了延迟。如果您使用下面的代码,它可能会起作用。
`- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
你在做
iOS6+
吗?如果是,那么我建议您遵循它的autoLayout
功能。一步步看一遍开始 iOS 6 中的自动布局,你就会明白autoLayout
的美妙之处。在 autoLayout
中,无需在代码中手动设置框架的位置。