enter image description here我在 ViewController
中使用 CarbonKit
。它工作正常。在这里,我对所有段数组标题 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 Controller 的 Root View Controller ,我认为如果你使用一个不同的 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
}
关于ios - 碳套件 : How To pass tab array title ID to UIViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46987417/