I have created a UIViewController
in Storyboard
that contains a UITableView
.
class ViewController: UIViewController, UITableViewDataSource
{
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad()
{
super.viewDidLoad()
}
override func viewDidAppear(_ animated: Bool)
{
super.viewDidAppear(animated)
print(self.tableView.subviews) //HERE..!!!
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return 5
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
return tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
}
}
Issue: I am facing issue with subViews
of UITableView
.
In iOS-10, when executing tableView.subviews
, I am getting UITableViewWrapperView
as one of the elements along with other elements in the array.
But in iOS-11, UITableViewWrapperView
is not available in the array returned by tableView.subviews
.
Due to this, I am facing issue with hitTest:withEvent:
that I have overridden on UITableView
.
In iOS-11, Apple removed UITableViewWrapperView
from the table view
hierarchy as confirmed in the link: https://forums.developer.apple.com/thread/82320
I was facing issue with hitTest:withEvent:
because it was earlier applied on tableView.subviews.first
i.e. UITableViewWrapperView
.
Now, I applied hitTest
on the UITableView
itself instead of its wrapper view
, i.e.
class TableView: UITableView
{
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView?
{
if let hitView = super.hitTest(point, with: event) , hitView != self
{
return hitView
}
return nil
}
}
Finally got it working.