首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UITableView subViews不包含UITableViewWrapperView iOS 11

UITableView subViews不包含UITableViewWrapperView iOS 11
EN

Stack Overflow用户
提问于 2017-11-06 09:49:29
回答 1查看 248关注 0票数 0

我在Storyboard中创建了一个包含UITableViewUITableView

代码语言:javascript
复制
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中,UITableViewWrapperViewtableView.subviews返回的数组中不可用.

因此,我面临着hitTest:withEvent:的问题,我已经在UITableView上重写了这个问题。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 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,即

代码语言:javascript
复制
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
    }
}

终于起作用了。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47134016

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档