UITableView portion loses interaction after device

2019-07-03 06:18发布

问题:

I have a UIViewController with a UIView subclass as a subview, and in here is a UITableView added as a subview of that UIView, as follows:

UIViewController
-UIView
--UITableView (plucked from a UITableViewController)

On an iPad, if I load the view controller in either orientation I can interact with the table view perfectly. However, if I rotate the device to a new orientation - I have code that alters the frames to make it fit the new resolution, but a small area of the table does not respond to touches and whatnot.

eg, we rotate portrait to landscape: if you imagine a portrait shape placed over a landscape screen - this area remains responsive, but a small strip to the right hand side does not respond.

Does anyone have any ideas what I may have missed? Thanks in advance.

EDIT: I have successfully verified the CGRect frames of all objects from the tableview cells through to the top UIViewController.

回答1:

The area that looses its interaction must have fallen outside its superview's frame after rotation.

you can check that by setting tableView.clipSubviews = YES;

using this, will crop the tableview portion falling outside the superview.