'ios 15.2 Objective-C Mutiple UITableViews on single screen crashing when scrolling

I have two UITableViews on my view with two buttons acting as tabs on top of the view. I hide and show one of the tableview based on user selection. When I come to the view everything seems fine with first tab selected and tableview loaded with data , when I move to second tab the data on the second UItableView is loaded and visble but when I try to scroll the app is crashing.

Crash is happening at tableView:heightForRowAtIndexPath:].

  • (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

When I print the table tag and indexPath in the above method it is still pointing to UITableView from first tab which is hidden.

But when I do a scroll action on first tab UITableView and then go the second tab I am able to scroll the UITableView.

Things were working fine on previous version on ios.

I appreciate any help.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source