从不同场景返回时,静态表格视图单元格保持突出显示
Static tableview cell stays highlighted when returning from different scene
我有一个 uiviewcontroller,上面有一个容器,里面嵌入了一个 uitableviewcontroller,它有静态单元格和静态内容。当我点击单元格 "Trip Info" 时,它会转至 Trip Info View Controller。返回时,静态单元格会突出显示。
我看过很多帖子说要在 didselectrow tableview 方法中添加代码,但我没有使用,因为我的内容是静态的。有什么想法吗?
好的,仅仅因为您有静态内容并不意味着您可以跳过使用 tableview 委托。设置起来并不难。
tableView.deselectRowAtIndexPath(index)
没有别的办法了。
最后我自己弄明白了。
您需要为嵌入到 UIViewController 中的 UITableViewController 创建一个 swift 文件。
然后确保你的tableview是一个delegate,然后调用
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: true)
}
在您创建的新文件中。
我有一个 uiviewcontroller,上面有一个容器,里面嵌入了一个 uitableviewcontroller,它有静态单元格和静态内容。当我点击单元格 "Trip Info" 时,它会转至 Trip Info View Controller。返回时,静态单元格会突出显示。
我看过很多帖子说要在 didselectrow tableview 方法中添加代码,但我没有使用,因为我的内容是静态的。有什么想法吗?
好的,仅仅因为您有静态内容并不意味着您可以跳过使用 tableview 委托。设置起来并不难。
tableView.deselectRowAtIndexPath(index)
没有别的办法了。
最后我自己弄明白了。
您需要为嵌入到 UIViewController 中的 UITableViewController 创建一个 swift 文件。
然后确保你的tableview是一个delegate,然后调用
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: true)
}
在您创建的新文件中。