【发布时间】:2016-04-26 08:25:50
【问题描述】:
我是一名初级 iOS 开发人员。 目前我正在开发一个应用程序,我想创建设置,所以我有一个 UITableViewController 包含一个带有类别的 UITableView,当你点击一个单元格时,你应该显示另一个 UITableView 包含点击类别的所有值。 这是代码:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?)
{
if segue.identifier == "getValueFromCategory" {
let viewController = (segue.destinationViewController as? UnitTableViewController)!
let indexPath = self.tableView.indexPathForSelectedRow!.row
print(indexPath)
segue.
//print(viewController)
viewController!.toPass = self.categories[indexPath].titleCategory
}
}
如果我取消注释 let viewController 行,我会收到此错误:无法将类型“UITableViewController”(0x10b635c10)的值转换为“fitness.UnitTableViewController”(0x108196d48)。
如果有人知道我做错了什么,它会有所帮助!
谢谢!
【问题讨论】:
-
请发布当前类名和目标类名及其属性
-
为什么不使用 didSelectedRowAtIndex 去另一个 ViewController ?
标签: ios iphone swift uitableview uiviewcontroller