gpt4 book ai didi

iphone - UIToolBar 和 iPhone 界面方向问题

转载 作者:行者123 更新时间:2023-12-03 20:49:50 25 4
gpt4 key购买 nike

我正在 iPhone 中开发一个应用程序。一个 View 支持纵向和横向方向。我对两个方向都有两个单独的 View 。该 View 顶部有一个 UIToolbar

问题是当我将 View 从横向更改回纵向时,顶部的 UIToolbar 消失了。我希望工具栏在旋转回纵向时返回到其原始位置。

这就是我在程序中所做的事情:

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)
interfaceOrientation duration:(NSTimeInterval)duration {
if (interfaceOrientation == UIInterfaceOrientationPortrait)
{
self.view = self.portrait;
self.view.transform = CGAffineTransformIdentity;
self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(0));
self.view.bounds = CGRectMake(0.0, 0.0, 300.0, 480.0);
}
else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft)
{
self.view = self.landscape;
self.view.transform = CGAffineTransformIdentity;
self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(-90));
self.view.bounds = CGRectMake(0.0, 0.0, 460.0, 320.0);
}
else if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
self.view = self.portrait;
self.view.transform = CGAffineTransformIdentity;
self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(180));
self.view.bounds = CGRectMake(0.0, 0.0, 300.0, 480.0);
}
else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
self.view = self.landscape;
self.view.transform = CGAffineTransformIdentity;
self.view.transform =
CGAffineTransformMakeRotation(degreesToRadian(90));
self.view.bounds = CGRectMake(0.0, 0.0, 460.0, 320.0);
}
}

我不知道我在这里错过了什么?任何帮助将不胜感激。

最佳答案

在界面构建器中,选择工具栏,点击command-3;这将打开标尺/对齐控制菜单。

在“Autsizing”部分下,默认情况下工具栏仅与左右和中心耦合。不去TOP。选择顶部的“I”。现在工具栏相对于 View 顶部停靠,并且在旋转过程中不会被推开。

我确信也有一个等效的代码

关于iphone - UIToolBar 和 iPhone 界面方向问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1814154/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com