CarbonKit:如何将选项卡数组标题 ID 传递给 UIViewController?

CarbonKit : How To pass tab array title ID to UIViewController?

enter image description here我在 ViewController 中使用 CarbonKit。它工作正常。在这里,我对所有 Segment Array 标题 ID 使用一个 tableview。当我选择 Tab 并滑动时我得到了标题 ID,并且当我从左更改索引时坚持将数组标题 ID 传递给服务器(TableView)---> 右和右 ---> 左。

我的代码:名称数组

 self.carbonTabSwipeNavigation = CarbonTabSwipeNavigation(items: self.names as [AnyObject], delegate: self)

设置ViewController

 func carbonTabSwipeNavigation(_ carbonTabSwipeNavigation: CarbonTabSwipeNavigation, viewControllerAt index: UInt) -> UIViewController {

    studentid = studentidArray.object(at: Int(index)) as! String
    print(studentid)
    return self.storyboard!.instantiateViewController(withIdentifier: "LeaveTableVC") as! LeaveTableVC
}

我已经在 'ViewController' 和 'tableview' 上显示了名字。现在我需要在滑动并点击细分选项卡时将 ID 名称发送到服务器。请帮助我卡住了。谢谢

好吧,如果我明白你的 LeaveTableVC 是 Carbon Kit 控制器的根视图控制器,我认为如果你使用不同的 TableViewController 会更好,它可能对你的所有选项卡都是相同的,但无论如何studentID 不是您的新 LeaveTableVC 实例 属性,而是当前的 LeaveTableVC 属性。所以例如你需要做:

func carbonTabSwipeNavigation(_ carbonTabSwipeNavigation: CarbonTabSwipeNavigation, viewControllerAt index: UInt) -> UIViewController {
    let nextVC = self.storyboard!.instantiateViewController(withIdentifier: "LeaveTableVC") as! LeaveTableVC
    nextVC.studentid = studentidArray.object(at: Int(index)) as! String
    print(studentid)
    return nextVC
}