swift 中使用tabbar 来控制viewController跳转
发布时间:2020-12-14 01:54:19 所属栏目:百科 来源:网络整理
导读:在swift中通过 storyboard或者编程的方法 来实现一个 UITabBarController 进行各个UIViewController进行切换 相关阅读:http://makeapppie.com/2014/09/09/swift-swift-using-tab-bar-controllers-in-swift/ 前面那个方法是放在AppDelegate中实现的。而现实
//
// ChartViewController.swift
// iLiveTraffic
//
// Created by 徐泽宇 on 15/8/14.
// Copyright (c) 2015年 徐泽宇. All rights reserved.
//
import UIKit
class ChartTabBarController: UITabBarController,UITabBarDelegate {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func tabBar(tabBar: UITabBar,didSelectItem item: UITabBarItem!) {
NSLog("tabbar item 被点击")
switch item.tag{
case 0:
//是退出按钮
self.dismissViewControllerAnimated(true,completion: nil)
case 1:
NSLog("点击图表1")
case 2:
NSLog("点击图表2")
case 3:
NSLog("点击图表3")
case 4:
NSLog("点击图表4")
default:
NSLog("未知按钮")
}
}
}
var chartTabBarController: ChartTabBarController! = UIStoryboard(name: "Main",bundle: nil).instantiateViewControllerWithIdentifier("chartTabBarController") as! ChartTabBarController
presentViewController(chartTabBarController,animated: true,completion: nil)
相关阅读: (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |