Reputation: 514
I have a static view, its a settings view. It has 3 sections
section 1 has 3 rows
section 2 has 1 row
section 3 has 1 row
I wired up the UISwitch's in each row, which all work fine. The last row s3-r1 I need to react to a selection. Its a UITableViewController do I override didDeselectRowAtIndexPath and added:
if indexPath.section == 2 && indexPath.row == 0 {
// do something here - yes there's more than a comment in here
}
nothing happened. So I did this:
override func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
println("section \(indexPath.section) row \(indexPath.row)")
}
Doesn't matter where I start, the first row I select prints nothing, then they're all out of order. For example.
user action = println output
touch section 1 - row 1 = (nothing+
touch section 1 - row 2 = section 0 row 0
touch section 1 - row 3 = section 0 row 1
touch section 2 - row 1 = section 0 row 2
touch section 3 - row 2 = section 1 row 0
Next I created an outlet to the cell I want to react and tried this instead:
let cell: UITableViewCell = tableView.cellForRowAtIndexPath(indexPath)!
if cell == cellOutlet {
println("!!!")
}
This does print but randomly from different cells
I've been googling for hours and I have no idea what's going on. Why are the seemingly in random order? Help Obi-wan
Upvotes: 0
Views: 39
Reputation: 534893
The problem appears to be that you have overridden the wrong method. It isn't didDeselect
you care about — it's didSelect
. Override that method and you'll be fine.
Upvotes: 3