无法在标签栏 Swift 2 中将文本添加到列表视图

Cant add text to listview in Tab bars Swift2

我使用此代码为标签栏项目设置标题。它适用于前 5 个。但是当第六个应该将文本添加到 "more" 下的列表视图时,应用程序崩溃。如何设置该列表中的文本?

    let tabArray = self.tabBarController?.tabBar.items as NSArray!

    let tabItem1 = tabArray.objectAtIndex(0) as! UITabBarItem
    let tabItem2 = tabArray.objectAtIndex(1) as! UITabBarItem
    let tabItem3 = tabArray.objectAtIndex(2) as! UITabBarItem
    let tabItem4 = tabArray.objectAtIndex(3) as! UITabBarItem
    let tabItem5 = tabArray.objectAtIndex(4) as! UITabBarItem
    let tabItem6 = tabArray.objectAtIndex(5) as! UITabBarItem

    tabItem1.title = "Home"
    tabItem2.title = NewArray().12
    tabItem3.title = NewArray().13
    tabItem4.title = NewArray().14
    tabItem5.title = NewArray().15
    tabItem6.title = NewArray().16

试试这个:

let viewControllerArray = self.tabBarController?.viewControllers as [UIViewController]!
let tabItem1 = viewControllerArray[0].tabBarItem
let tabItem2 = viewControllerArray[1].tabBarItem
let tabItem3 = viewControllerArray[2].tabBarItem
let tabItem4 = viewControllerArray[3].tabBarItem
let tabItem5 = viewControllerArray[4].tabBarItem
let tabItem6 = viewControllerArray[5].tabBarItem

tabItem1.title = "Home"
tabItem2.title = NewArray().12
tabItem3.title = NewArray().13
tabItem4.title = NewArray().14
tabItem5.title = NewArray().15
tabItem6.title = NewArray().16