ios14 , TableView:didSelectRowAtIndexPath not called

Viewed 391

after ios14 update TableView:didSelectRowAtIndexPath is not called. Running the same source in ios13 works normally

tableview A Click to add to the parent view [self.superview addsubview:A] I added a table view like this So the delegate is received from the current view Until ios13 is normal, why not?

2 Answers

There are two methodologies:

First

When you're using UITableViewController then it's automatically conformed to UITableViewDataSource and UITableViewDelegate protocols.

@interface UITableViewController : UIViewController;

Second

In case you're using UITableView you have to conform it to both protocols – UITableViewDataSource and UITableViewDelegate and assign two class delegates.

@interface UITableView : UIScrollView;

@property(nonatomic, weak) id<UITableViewDelegate> delegate;
@property(nonatomic, weak) id<UITableViewDataSource> dataSource;

If both methodologies don't work, so it's definitely a bug in iOS 14.

About method:

tableView:didSelectRowAtIndexPath:

Apple documentation says:

The system doesn’t call this method if the rows in the table aren’t selectable. See Handling Row Selection in a Table View for more information on controlling table row selection behavior.

This is for sure an iOS 14 bug, I ran into the same issue (I believe). I think this twitter post sheds some light on the issue. Assuming your issue is the same as mine, you are now required to add subviews on cells to their contentViews. https://twitter.com/smileyborg/status/1276623198059036672

[tableViewCell addSubView:] - > [tableViewCell.contentView addSubView:]
Related