我正在开发一个 iPhone 应用程序,我想为纵向视图和横向视图创建单独的布局。在纵向布局中,我有 2 列和 3 行方形按钮(这是通过界面生成器中的 xib 完成的)。在景观中,我想要 3 列 2 行。这可能吗?我添加了以下我认为可能适用的代码。
- (void)willAnimateRotationToInterfaceOrientation:
(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
NSLog(@"Landscape Rotation Occurred");
scriptureButton.frame = CGRectMake(20, 20, 130, 130);
characterSketchButton.frame = CGRectMake(170, 20, 130, 130);
mapButton.frame = CGRectMake(320, 20, 130, 130);
storyingButton.frame = CGRectMake(20, 170, 130, 130);
videoButton.frame = CGRectMake(170, 170, 130, 130);
otherResourcesButton.frame = CGRectMake(320, 170, 130, 130);
}
else
{
NSLog(@"Portrait Rotation Occurred");
scriptureButton.frame = CGRectMake(20, 20, 130, 130);
characterSketchButton.frame = CGRectMake(170, 20, 130, 130);
mapButton.frame = CGRectMake(20, 170, 130, 130);
storyingButton.frame = CGRectMake(170, 170, 130, 130);
videoButton.frame = CGRectMake(20, 320, 130, 130);
otherResourcesButton.frame = CGRectMake(170, 320, 130, 130);
}
}