Bundle.main.loadNibNamed中的内存泄漏

时间:2019-02-11 13:33:50

标签: swift memory-leaks

我的课程BottomTabView上发生了奇怪的内存泄漏。 我有class func通过xib

Bundle.main.loadNibNamed加载它的类实例
@objc class func loadFromNib() -> BottomTabView? {
    if let topLevelObjects = Bundle.main.loadNibNamed("BottomTabView", owner: nil, options: nil) { // <<< this is a memory leak
        if topLevelObjects.count > 0 {
            let view = topLevelObjects[0] as? BottomTabView
            if let view = view {
                var rect = view.frame
                rect.size.height = BottomTabView.Height
                view.frame = rect

                view.shiftConstraint?.constant = BottomTabView.Shift
            }
            return view
        }
    }
    return nil
}

instrument screenshot

我该如何解决?我不明白是什么原因。

0 个答案:

没有答案