如何在 SWIFT 中使用没有 tabBar 控制器的 tabBar



我使用以下代码检查在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

最新更新