我使用以下代码检查在TabBar
中选择了哪个选项卡,UIViewController
不使用UITabBarController
,但是我不知道如何在视图中加载特定的视图控制器,或者有没有其他方法可以实现这一点
这是我从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博尔切特 我使用了标签栏控制器这完全解决了我的问题
TabBarController with SWRevealViewController
谢谢@Anbu.Karthik