我在Storyboard中创建了一个包含UITableView的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)
}
}问题:我正面临着subViews of UITableView的问题。
在iOS-10中的中,在执行tableView.subviews时,我将UITableViewWrapperView与数组中的其他元素一起作为元素之一。
但是在iOS-11中,UITableViewWrapperView在tableView.subviews返回的数组中不可用.
因此,我面临着hitTest:withEvent:的问题,我已经在UITableView上重写了这个问题。
发布于 2017-11-07 06:11:52
在iOS-11中,苹果从table view层次结构中删除了UITableViewWrapperView,如链接:https://forums.developer.apple.com/thread/82320中所确认的那样。
我面临着hitTest:withEvent:的问题,因为它更早地应用于tableView.subviews.first,即UITableViewWrapperView。
现在,我将hitTest应用于UITableView本身,而不是它的wrapper view,即
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
}
}终于起作用了。
https://stackoverflow.com/questions/47134016
复制相似问题