问题
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.
回答1:
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.
回答2:
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];
回答3:
Workaround: set the opacity(0.01) like this self.view.backgroundColor = [UIColor colorWithWhite:1 alpha:0.01];
回答4:
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)
来源:https://stackoverflow.com/questions/26223537/ios-today-extension-table-view-rows-only-detects-taps-on-a-label