iOS Today Extension Table View Rows only detects taps on a label
Asked Answered
U

4

6

I am having the weirdest of problems with a today widget on iOS.

I have a simple widget with a table view like this: https://grab.edr.io/2e557aa43a34b7460b1eac44cbcaf596.png

The thing is, it only responds to touches (the rows only get highlighted) when I tap one of the labels, and not the rest of the row (which is blank).

This happens on both device and simulator.

I am detecting touches using tableView:didSelectRowAtIndexPath:, so I am not being able to see a problem there.

Here is a screenshot of my storyboard: https://grab.edr.io/c2dc09db20ded2b471dc94ea339141b8.png

Any help or idea would be greatly appreciated!

Thanks.

Uvula answered 6/10, 2014 at 19:35 Comment(0)
U
9

Got an answer back from Apple's Developer Support.

It's an iOS 8 bug.

A workaround for it is to set the opacity of the widget to 0.01.

Uvula answered 11/11, 2014 at 14:4 Comment(2)
When you say setting the opacity of the widget, do you mean the main view, the table view, or something else?Halpern
How do I set the opacity?Teodor
T
7

Using the workaround of a background view with a white background color and alpha of 0.01 causes a slightly visible border on iPads where the notification center doesn't cover the whole screen, especially on the right edge of the table view.

Another workaround without this visual glitch is to use a UILabel as the cell's backgroundView. The label needs no text or background color.

self.backgroundView = [UILabel new];
Trantham answered 11/2, 2015 at 15:6 Comment(1)
not wanting to have to write code, and to be able to rely on the storyboard, i simply made the constraints for auto-layout make the labels inside my cell cover the entire contentView so a tap anywhere works.Endear
F
0

Workaround: set the opacity(0.01) like this self.view.backgroundColor = [UIColor colorWithWhite:1 alpha:0.01];

Fossil answered 11/2, 2015 at 6:39 Comment(0)
H
0

Swift 2.1 / iOS 9.1 solution:

self.view.backgroundColor = UIColor(red: (255.0/255.0), green: (255.0/255.0), blue: (255.0/255.0), alpha: 0.01)
Hydrometeor answered 23/11, 2015 at 10:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.