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

北战南征 提交于 2020-01-10 04:04:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!