Reputation: 248
UIButton within a UITableViewCell is set to selected. When checking the button property on didSelectRowAtIndexPath shows as false.
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
tableView.deselectRowAtIndexPath(indexPath, animated: true)
var cell:UserActionsTableViewCell = self.tableView.dequeueReusableCellWithIdentifier("userActionsCell") as! UserActionsTableViewCell
if (cell.followButton.selected){
//selected
}
else{
// not selected
}
How do I need to access the selected property?
Upvotes: 0
Views: 57
Reputation: 3984
Don't use dequeueReusableCellWithIdentifier
method in table didSelectRowAtIndexPath
delegate method.
try this code :
let cell = tableView.cellForRowAtIndexPath(indexPath) as! UserActionsTableViewCell // get selected cell and use cell subView contains..
if (cell.followButton.selected){
//selected
}
else{
// not selected
}
Upvotes: 1