Our DNA is written in Swift
Jump

Table View Cells lose clickability in Today Widget

While working on a today widget I stumbled on a bug in iOS. Since I was using multiple rows I had changed my widget to be table view-based with multiple rows showing a label and a value. Oddly, this setup caused my table view cells to no longer highlight when being touched between the labels.

There is a workaround of course, see below, but it is ugly. Filed as rdar://23298579 and on Open Radar. The mentioned sample app is WidgetTabCellTest on my Radar Samples repo on GitHub.

Ad

Summary

You can use a table view as base for a Today Widget. iOS will magically do some setup, like remove the background color and set the correct effect on the separators.

BUT: Some of this magic causes cells to no longer responds to taps outside of the areas which are covered by textLabel and detailTextLabel.

This is even more of a problem if you use the “Right Detail” cell because then a large space opens up between the labels which is not responsive. Also we are supposed to left-align the table view contents with the widget title, which causes a large unresponsive area in the left margin.

A workaround is to set a background color on the cells with an alpha of at least 0.01 – but you should be required to do that.

Steps to Reproduce

  1. Launch the Today Widget of the provided sample app in Simulator
  2. You see three rows.
  3. On the first row you see that the selection highlight shows if you tap inside the text label, but not if you tap outside left or right of it
  4. On the second row, which is a .Value1 style, the area in the middle does not react to touches
  5. On the third row I have added a 99% translucent background color as a workaround, this way you can tap anywhere and the selection highlight shows

Expected Results

All rows should highlight regardless of where you touch them

Actual Results

Without the workaround the cells only highlight if you tap in the areas covered by labels.

Screen Shot 2015-10-28 at 19.09.01

 


Categories: Bug Reports

1 Comment »

  1. Much appreciated! This was driving me crazy.