SWIFT 如何在没有 tabBarController 的情况下使用 tabBar
How to use tabBar without tabBarController in SWIFT
我使用下面的代码来检查 TabBar
在 UIViewController
中选择了哪个选项卡,而不是使用 UITabBarController
,但我不知道如何加载特定的 ViewController在视图中,或者有没有其他方法可以实现这个
这是我从 Google 和其他论坛得到的,我使用 UITabBarItems
的标签来区分按钮
import UIKit
class AdminViewController: UIViewController, UITabBarDelegate {
@IBOutlet weak var menuButton: UIBarButtonItem!
@IBOutlet weak var tabbar: UITabBar!
override func viewDidLoad() {
super.viewDidLoad()
if self.revealViewController() != nil {
menuButton.target = self.revealViewController();
menuButton.action = "revealToggle:";
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer());
}
tabbar.delegate = self;
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem!) {
println(item.tag);
if(item.tag == 1)
{
//Want to load UIViewController into the CurrentViewController
}
}
}
我有另外一个想法,但是不太好
将 TabBar
放在所有 UIViewControllers
中,当单击 TabBarItem
时,我将使用 PerformSegue 导航到 UIViewController
并且还有一个 TabBar
是的@Oliver Borchert 我使用了标签栏控制器
这完全解决了我的问题
TabBarController with SWRevealViewController
谢谢@Anbu.Karthik
我使用下面的代码来检查 TabBar
在 UIViewController
中选择了哪个选项卡,而不是使用 UITabBarController
,但我不知道如何加载特定的 ViewController在视图中,或者有没有其他方法可以实现这个
这是我从 Google 和其他论坛得到的,我使用 UITabBarItems
的标签来区分按钮
import UIKit
class AdminViewController: UIViewController, UITabBarDelegate {
@IBOutlet weak var menuButton: UIBarButtonItem!
@IBOutlet weak var tabbar: UITabBar!
override func viewDidLoad() {
super.viewDidLoad()
if self.revealViewController() != nil {
menuButton.target = self.revealViewController();
menuButton.action = "revealToggle:";
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer());
}
tabbar.delegate = self;
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem!) {
println(item.tag);
if(item.tag == 1)
{
//Want to load UIViewController into the CurrentViewController
}
}
}
我有另外一个想法,但是不太好
将 TabBar
放在所有 UIViewControllers
中,当单击 TabBarItem
时,我将使用 PerformSegue 导航到 UIViewController
并且还有一个 TabBar
是的@Oliver Borchert 我使用了标签栏控制器 这完全解决了我的问题
TabBarController with SWRevealViewController
谢谢@Anbu.Karthik