I Use the following code to check which tab is selected in TabBar
in UIViewController
not using UITabBarController
, But i don't know how to load the Particular ViewController in the View, Or is there any other way to achieve this
This is what i get from the Google and other forums, I use the Tag for the UITabBarItems
to differentiate the buttons
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
}
}
}
I have another idea, But it is not good
Place the TabBar
in all UIViewControllers
and When the TabBarItem
is Clicked i will Navigate to that UIViewController
using PerformSegue & There also a TabBar
Yes @Oliver Borchert I used the tab bar controller This solved my problem completely
TabBarController with SWRevealViewController
Thanks @Anbu.Karthik