Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView "bulk select" not showing selected checkmarks in the selection circles, showing right side checkmark not left side

I am attempting to reproduce this behavior (see screenshot below, the "mail multiple select to delete" behavior) on an iOS8 Swift application. When set to "edit" the left selection circles are presented, but upon selection they do not change to a blue checkmark. (Nothing visible happens, or it happens off to the right ... off screen.)

From various Google searches I've tried setting the accessoryType to be checkbox, but that appears on the right (not the left.) [Is that old advice, is adding a checkmark still the approach to take?]

I've scoured this sample (even downloading it and running it and tweaking it closer to my code, and it works) but I cannot see the delta between it and my application.

Some data points:

  • Xcode 7
  • iOS8 + (testing on 8 and 9)
  • Swift 2.0
  • Storyboard configuration of the tableview, etc.
  • Custom layout cells. They use the content view for some text, nothing outside. Autolayout.
  • Single selection when NOT editing (or so I believe)
  • Multiple selection when editing (to get this effect.)
  • DataSource returns canEdit "true" for most (not all) cells. Circles only show next to those editable, matching expectations.
  • Delegate is not returning any "editing style" value. (Tried w/ & w/o.)
  • Delegate does NOT deselect in "didSelect" handler.
  • When I try setting accesoryType to Checkmark in didSelect (which many posting suggest, but I don't see it in the sample) it comes on the right not left.

Other StackOverflow questions / answers imply something is causing UITableView to fail to know to put the checkmark on the left not the right. I can believe that, but I cannot find it. Any help appreciated.

The desired effect (from sample screenshot):

https://developer.apple.com/library/ios/samplecode/TableMultiSelect/Introduction/Intro.html

The blue  checkbox selection from sample

Table Settings

Table Settings from Storyboard

Table Cell Settings

Table Cell Settings from Storyboard

like image 723
Adam Jack Avatar asked Sep 17 '15 20:09

Adam Jack


2 Answers

If you have selectionStyle = .None in your cellForRowAtIndexPath, remove it.

I was in the same exact boat as you (using Xcode 7, iOS9, Swift 2.0). Most of the articles I found online were about the checkmark on the right and my storyboard looked perfect. My only problem is that I could never get the checkmark on the left to show up when I tapped on the row.

With your post I was able to compare source code and figure it out - thanks!

like image 127
Jennifer Starratt Avatar answered Oct 25 '22 09:10

Jennifer Starratt


Make sure cell's tint color is NOT white, otherwise you will get a white checkmark over a white circle...

like image 20
rjobidon Avatar answered Oct 25 '22 08:10

rjobidon