如何使用 Objective C 在 iPhone 中添加 UITabBar
如何以编程方式为 iPhone 应用程序添加 UITabBar。需要一些建议和示例代码。
How to add add UITabBar programmatically for iphone app. Need some suggestion and sample code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这里有两个方面......
第一个方面(UITabBarController):
在这里,您可以将多个类(即 Viewcontrollers)添加到 UITabBarController,如前面的答案所示...
第二个方面(UITabbar):
在这里,您可以在任何视图控制器中添加选项卡栏...对于此选项卡栏,您可以添加多个 UITabBar 项目...并且您可以获得单独的选项卡栏项目操作...
请参阅下面的 UITabBar 代码
---------> 添加UITabBar
---------> 向 UITabBar 添加项目
---------> 在委托方法中获取项目操作
更新:(Swift 2.0)
1. 第一个方面(UITabBarController):
这将允许我们将
UIViewController
配置为UITabBarController
中的tabbar
项。下面是UITabBarController的基本方法:
--------->将 UITabBarController 添加到 appdelegate 中的窗口
--------->配置UIViewControllers
--------->将 UIViewController 附加到 UITabBarController
--------->在“UITabBarControllerDelegate”中接收事件
2.第二个方面(UITabBar):
这将允许我们创建
tabbar
项目。我们可以在委托方法中获取单个项目的事件以下是UITabBar的基本方法:
--------->将 UITabBar 添加到视图
--------->准备 TabbarItems
--------->将UITabBarItems添加到UITabBar
--------->在“UITabBarDelegate”中接收事件
Here the two aspects....
First Aspect (UITabBarController):
Here You can add multiple classes (i.e Viewcontrollers) to the UITabBarController as show in the previous answers...
Second Aspect (UITabbar):
Here You can add the Tabbar in any view controller...And for this Tabbar you can add multiple UITabBar Items..and You can get the individual Tabbar Item Action.....
See the Below Code For UITabBar
---------> Adding UITabBar
---------> Adding Items to UITabBar
---------> Getting The Item Actions in a Delegate Method
Update: (Swift 2.0)
1. First Aspect (UITabBarController):
This will allow us to configure
UIViewController
s astabbar
items inUITabBarController
.Below is the basic approach for UITabBarController:
---------> Adding UITabBarController to window in appdelegate
---------> Configuring UIViewControllers
---------> Attaching UIViewControllers to UITabBarController
---------> Receiving event in 'UITabBarControllerDelegate'
2. Second Aspect (UITabBar):
This will allow us to create
tabbar
items. We can get event for individual item in delegate methodBelow is the basic approach for UITabBar:
---------> Adding UITabBar to a view
---------> Preparing TabbarItems
---------> Adding UITabBarItems to UITabBar
---------> Receiving event in 'UITabBarDelegate'
这是以编程方式制作 TabBarController 的代码。
希望这会对您有所帮助。
Here is the code for making TabBarController programmatically.
Hope this will help you.
这就是你可以做的
这将创建一个带有四个选项卡的选项卡栏,每个选项卡都有自己的视图控制器和导航控制器,即每个选项卡维护自己的堆栈来推送和弹出视图控制器。
我希望这对U有帮助。
here is what u can do
This will create a tab bar with four tabs and each tab with its own viewcontroller and navigation controller, i.e each tab maintains its own stack to push and pop the view controller.
I hope that helps U.
您可以执行以下操作:
要向其中添加一些项目,您可以编写:
You can do something like:
To add some items to it, you can write: