gpt4 book ai didi

iphone - 推送新 View 时删除工具栏

转载 作者:搜寻专家 更新时间:2023-10-30 20:07:54 25 4
gpt4 key购买 nike

在 iPhone map 应用程序中, map View 底部有一个工具栏(它包含搜索/方向分段控件和其他控件)。通过单击标注从 map View 移动时,工具栏会与 map View 一起滑出,留下没有工具栏的下一个 View (表 Controller )。

我试图在第二个 View Controller 中用 [self.navigationController setToolbarHidden:YES animated:YES] 做同样的事情,但这会产生一个奇怪的工具栏向下滑动动画,而 map View 向左滑动。

viewDidLoad 中使用 [self.navigationController setToolbarHidden:YES] 也会导致不好的效果(它使工具栏在推送动画开始的那一刻消失,留下难看的白色空格)。

我假设这个问题的答案是使用 nib 文件,但我更愿意以编程方式进行(如果可能)。

当我按下一个新的 View Controller 时,如何让工具栏“粘”到 map View 上并随之滑出?谢谢。

Gourmet Haus Staudt http://img.skitch.com/20100518-xfubyriig48d3ckaemjg2ay8q.jpg

最佳答案

原来答案是直接创建工具栏,然后自己添加到 View 中。这是在带有 UINavigationControllerUIViewController 的代码中。框架坐标可以根据屏幕上的内容而变化。

- (void)viewDidLoad
{
// Add a toolbar to the view
CGRect toolbarFrame = CGRectMake(0, 372, 320, 44);
UIToolbar *myToolbar = [[UIToolbar alloc] initWithFrame:toolbarFrame];

UIBarButtonItem *compassButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"compass.png"]
style:UIBarButtonItemStyleBordered
target:self
action:@selector(zoomToCurrentLocation)];

compassButton.width = 30.0f; // make the button a square shape
[myToolbar setItems:[NSArray arrayWithObject:compassButton] animated:NO];
[compassButton release];

[self.view addSubview:myToolbar];
[super viewDidLoad];
}

关于iphone - 推送新 View 时删除工具栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2856872/

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