I am new in swift4 and this is my first table view implementation.
I am using iPad for developing application and I can not resolve issue that table view setSelected function is called twice on click and always selected value is equals to true
As I saw in Web such behavior is only on iPad
So what is workaround fir this issue
My code is:
@IBOutlet weak var checkImage: UIImageView!
var showing = false
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
if selected {
if showing == false {
checkImage.isHidden = false
showing = true
}
else {
checkImage.isHidden = true
showing = false
}
}
}
Try using deselectRow(at:animated:)
in didSelectRow
:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at:indexPath animated:true)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.