UITableView: clicking in an empty area does not call didSelectRowAtIndexPath

When I develop the iOS8 Today Extension, I set the UITableViewController as the main view controller. And I met this problem:

When I start UITableViewCell using initWithStyle: UITableViewCellStyleDefault in cellForRowAtIndexPath the entire area of ​​one cell can call didSelectRowAtIndexPath as usual. However, when UITableViewCellStyle sets UITableViewCellStyleValue1, UITableViewCellStyleValue2 or UITableViewCellStyleSubtitle, I can only run didSelectRowAtIndexPath by clicking on the DetailsTextLabel or image area. Press another space area will not respond.

I tried to set the tableview delegate for myself, set detailTextLabel and imageView setUserInteractionEnabled: false to cellForRowAtIndexPath, and all this does not work. Does anyone know about this?

PS I do not use a storyboard or xib file, just code.

I found the same problem on Android: I would like to click anywhere (empty area) as a list

+7
ios select uitableview
source share
1 answer

I came across this myself while trying to display a UITableView inside TodayView . Although I don’t know why this is happening, I found out that this only happens when the background of the UITableViewCell is set to clearColor . If you set the background to a different color, didSelectRowAtIndexPath is didSelectRowAtIndexPath . However, here's a quick workaround - put a UILabel to stretch the entire area of ​​the contentView cell, and then the delegate method will be called every time. Anyway, this seems like a mistake.

+8
source share

All Articles