add tab bar without tab bar controller in swift

admin

Administrator
Staff member
I need to add an tab bar in my view with out tab bar controller, because in my
Code:
prepareForSegue
function I pass data to my view whitch contains the tab bar.

I add the tab bar from the object library with its items, and in my view class I add UITabBarDelegate.
my code is like this:

Code:
class SchedaCompletaVC: UIViewController, UITabBarDelegate {

var event:Event! // data passing from prepareforsegue

@IBOutlet var mainTabBar:UITabBar!
var descrizioneTab:UIViewController! //if i click on first tab, so my default view 
var mappaTab:UIViewController! // second tab

override func viewDidLoad() {
    super.viewDidLoad()
    println("event \(event.eventId)")

    // Do any additional setup after loading the view.
}

func tabBar(tabBar: UITabBar, didSelectItem item: UITabBarItem!) {
    switch (item.tag) {
    case 1:
        self.view.insertSubview(descrizioneTab.view.belowSubview(mainTabBar)) //here I had error
       break;
    case 2:
        //if second tab is selected
        break;
    default:
        break;
    }
}

I got this code from an <a href="http://nullpointr.wordpress.com/2012/02/18/ios-dev-add-tabbar-to-a-view-without-a-tabbarcontroller/" rel="nofollow noreferrer">tutorial</a> whitch is for objective-c, I tried to convert it in swift.

My code doesn't work, I don't know what to do?

Please help. Thank you!

Update:
my storyboard is like this: <img src=" " alt="enter image description here">