【发布时间】:2015-04-11 10:36:40
【问题描述】:
我有一个启用单选的常规 UITableView。我的问题是,如果用户选择多行,那么原始行仍然被选中。我也有一个问题,无论我设置 cell.selectionStyle = UITableViewCellSelectionStyle.Blue
我的视图控制器在 Storyboard 中定义。
表格视图
- 内容:动态原型
- 选择:单选
- 在触摸 [X] 时显示选择
- 背景:黑色
- 索引行限制:0
表格单元格视图
- 风格:自定义
- 选择:蓝色
- 背景:黑色
以下是一些截图:
这是我的代码:
class AreaViewController: UITableViewController
{
override func viewDidLoad()
{
super.viewDidLoad()
self.tableView.backgroundColor = backgroundColour
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCellWithIdentifier("areacell", forIndexPath: indexPath) as! UITableViewCell
cell.selectionStyle = UITableViewCellSelectionStyle.Blue
cell.textLabel?.text = "Cell Contents"
cell.textLabel?.textColor = UIColor.whiteColor()
return cell
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
{
let cell = tableView.dequeueReusableCellWithIdentifier("areacell", forIndexPath: indexPath) as! UITableViewCell
}
}
我一定遗漏了一些明显的东西,但我没有看到任何不标准的东西。
【问题讨论】:
标签: uitableview swift