如何使用选项卡栏在视图之间移动
我正在做一个基于 SingleView 的应用程序,其中我有许多 UIviewcontroller 类子类,用于从一个视图移动到另一个视图。我在其中一个视图中有一个选项卡栏,并且希望在单击选项卡时与其他视图进行通信。所以请告诉我该怎么做,我被困在这里了。 我有名为
LoginPage.h/.m/.xib
Myservices.h/.m/.xib
History.h/.m/.xib
Profile.h/.m/.xib
MyRecentRequest.h/.m/.xib
的 类我从登录页面进入,它移至“我的服务”视图。 我在底部添加了选项卡栏,并添加了两个选项卡项目,总共有 4 个选项卡栏项目,分别命名为 Myservices、history、MyrecentRequest 和 profile。
现在我想将选项卡栏与其他类连接,以便当我单击选项卡项时,应该出现该特定类的相应视图,那么我该如何执行此操作?请向我提供示例代码。
I am doing an application which is of SingleView BASED Application,where i have many UIviewcontrollerclass subclasses for moving from one view to another view.i have a tab bar in one of the view and want to communicate with others view when click on a tab.so plz tell me how can i do it i am stuck here.
i have classes called
LoginPage.h/.m/.xib
Myservices.h/.m/.xib
History.h/.m/.xib
Profile.h/.m/.xib
MyRecentRequest.h/.m/.xib
when i enter from login page it moves to Myservices view.
There i have added Tab bar at the bottom and added two more tab Items and totally have 4 tab bar items naming Myservices,history,MyrecentRequest and profile.
Now i want to connect the tab bar with other class so that when i click on tab item respective view should appear of that particular classs so how can i do this? please provide me sample code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,如何通过 IB 或代码维护 tabBar。下面如果通过代码。您需要为每个 tabItem 分配一个包含所有所需 viewController 的 tabBar,下面是具有 2 个 tabItem 的示例:
这样您就可以通过代码维护 tabBar,这样如果选择了选项卡,就会显示相应的视图,在此示例中每个选项卡中都使用导航控制器来提供导航,如果只需要 1 个视图,您可以避免使用导航控制器。
first of all how u r maintaining the tabBar, either from IB or code. The below if by code. You need to alloc a tabBar with all the viewControllers required into each tabItem, the below one is sample with 2 tabItems:
In this way u can maintain the tabBar by code, so that if tab is selected respective view will be shown, in this example a navigation controller is used in each tab to provide navigation, if only 1 view is required u can avoid the navigation controller..
为此,以下代码用于动态选择导航控制器并选择选择哪个选项卡。
这可能有助于创建应用程序
For that the following code is use to dynamically select the navigation controller and select the which tab is select.
this may be helpful to crate the application