使用 UITabBarController 添加持久 UIView
我有一个使用 UITabBarController 的应用程序,并且有另一个视图需要从选项卡栏控件后面向上滑动,但位于选项卡栏内容的前面。如果这还不清楚,请想象一个广告在选项卡式应用程序中向上滑动,该广告出现在除选项卡栏按钮之外的所有内容前面。
到目前为止,我的代码看起来像这样,但如果有更好的方法来执行此操作,我愿意更改它...
tabBarController.viewControllers = [NSArray arrayWithObjects:locationNavController, emergencyNavController, finderNavController, newsNavController, nil];
aboutView = [[AboutView alloc] initWithFrame:CGRectMake(0, window.frame.size.height - tabBarController.tabBar.frame.size.height - 37 ,
320, window.frame.size.height - tabBarController.tabBar.frame.size.height)];
[window addSubview:tabBarController.view]; // adds the tab bar's view property to the window
[window addSubview:aboutView]; // this is the view that slides in
[window makeKeyAndVisible];
目前 aboutView 是 UIView 的子类,位于底部的起始位置,但它隐藏tabBarController。如何更改此设置以使选项卡位于顶部,但仍将 aboutView 放在其他内容前面?
I have an app using a UITabBarController, and I have another view that needs to slide up from behind the tab bar controls, but in front of the tab bar's content. If that's not clear, imagine an advertisement sliding up in a tabbed app that appears in front of everything except for the tab bar buttons.
So far I have code that looks something like this, but I'm willing to change it if there's a better way to do this...
tabBarController.viewControllers = [NSArray arrayWithObjects:locationNavController, emergencyNavController, finderNavController, newsNavController, nil];
aboutView = [[AboutView alloc] initWithFrame:CGRectMake(0, window.frame.size.height - tabBarController.tabBar.frame.size.height - 37 ,
320, window.frame.size.height - tabBarController.tabBar.frame.size.height)];
[window addSubview:tabBarController.view]; // adds the tab bar's view property to the window
[window addSubview:aboutView]; // this is the view that slides in
[window makeKeyAndVisible];
Currently aboutView is a subclass of UIView and sits at its starting position at the bottom, but it hides the tabBarController. How can I change this to let the tabs be on top, but still have the aboutView in front of the other content?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将 aboutView 添加为当前活动视图控制器中视图的子视图 UITableBarController。您可以通过 selectedViewController 财产。
您可以将代码添加到 aboutView 实现中,以便在视图出现时为其设置动画。
我在弹出视图中执行类似的操作,我希望该视图出现在选项卡栏控件下。您可以将一些代码添加到 didMoveToSuperview 关于 aboutView 实现的消息:
因此,当您的 aboutView 添加到所选视图控制器的视图时,它会自动动画化。
You need to add the aboutView as a subview of the view in the currently active view controller in the UITableBarController. You can access that view via the selectedViewController property.
You can add code to your aboutView implementation to animate the view when it appears.
I do something like this in a popup view that I want to appear under the tab bar controls. You can add some code to the didMoveToSuperview message on the aboutView implementation:
So when your aboutView is added to the selected view controller's view, it automatically animates up.