通过单击第一个选项卡栏视图中的项目滑入第二个选项卡栏视图
我有一个带有三个选项卡的应用程序,当用户点击它们时,它们会立即切换视图。第一个视图是一个表格视图,选择要过滤的“位置类型”,以仅向第二个视图(MapView)显示这些引脚(添加这些注释)。
单击表格单元格时,它会使用以下代码立即切换到地图视图:
self.tabBarController.selectedIndex=1;
但是,我想使用从右侧滑入的动画来执行此操作,就像向下钻取表格视图层次结构时得到的动画一样。
我尝试了这个:
[self.navigationController pushViewController:[self.tabBarController.viewControllers objectAtIndex:1] animated:YES];
编译时没有错误或警告,但不切换视图。
如何将导航控制器“应用”到选项卡栏控制器上?或者有什么方法可以选择另一个视图控制器并指定动画?
I have an app with three tabs that switch views instantaneously when the user taps them. The first view is a table view selecting which 'location type' to filter by, to only show those pins (add those annotations) to the second view, a MapView.
When a table cell is clicked, it switches instantaneously to the mapview, using this code:
self.tabBarController.selectedIndex=1;
However, I would like to do this with a slide-in-from-right animation, like the one you get when drilling down a hierarchy of table views.
I tried this:
[self.navigationController pushViewController:[self.tabBarController.viewControllers objectAtIndex:1] animated:YES];
which compiles without error or warning, but does not switch views.
How do I 'apply' a navigation controller 'onto' a tab bar controller? Or is there some way to select another viewcontroller and specify an animation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您无法使用标签栏控制器来做到这一点,因为没有 API 来管理动画。您的选择是要么换出选项卡栏并使用按钮构建类似的东西,在这种情况下您可以管理自己的视图堆栈,要么放弃动画并只像您正在做的那样切换视图。
另一种方法是将地图显示为属于当前选项卡的导航控制器堆栈的一部分(假设您有导航控制器堆栈),但这实际上不会为您交换选项卡,只需将您移动到新位置即可你当前的堆栈。
I don't think you are going to be able to do that with a tab bar controller as there is no API to manage the animations. Your choices are either to swap out the tab bar and build something similar using buttons, in which case you can manage your own view stack, or to forgoe the animation and just switch views as you are doing.
An alternative approach is to display the map as part of the nav-controller stack belonging to your current tab - (assuming you have a nav controller stack) but that's not acutually going to swap tabs for you, just move you to a new place on your current stack.