__NSCFString nsli_lowerAttribute:intoExpression:withCoefficient:forConstraint:这只发生在 ios 10

__NSCFString nsli_lowerAttribute:intoExpression:withCoefficient:forConstraint: this occur in ios 10 only

我制作了一个在 ios 11 中运行良好的应用程序,但是当我尝试 运行 在 ios 10 中使用它时。它突然开始崩溃并出现此错误。

-[__NSCFType nsli_lowerAttribute:intoExpression:withCoefficient:forConstraint:]: unrecognized selector sent to instance 0x600000199cc0

我试图解决这个问题,但不知道为什么会这样。在异常断点中,它显示在

下方
 func showFullScreenLoading(inView objView:UIView?,withMsg strMsg:String = "Please wait!!!")
    {
        guard let view = objView else
        {
            return
        }

        let objParentView = UIView.init()
        objParentView.translatesAutoresizingMaskIntoConstraints = false
        objParentView.backgroundColor = UIColor.white.withAlphaComponent(0.2)
        objParentView.tag = -123456
        view.addSubview(objParentView)

        view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|[objParentView]|", options: [], metrics: nil, views: ["objParentView":objParentView])) //At this line exception error
        view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[objParentView]|", options: [], metrics: nil, views: ["objParentView":objParentView]))
}

Calling of the function

 func apiCalled(_ objOperation:TagApiOperation){

    self.currentRequest = objHomeViewModel.apiCallHome(objOperation: objOperation, withDictData: [:], withLoaderBlock: { (isStart) in
        if isStart{
            SINGLETON.showFullScreenLoading(inView: self.view) // I called this function in view did load and there will be no background thread are there
        }else{
            SINGLETON.hideFullScreenLoading(inView: self.view)
        }
    }) { (isStatus, strMsg, arrBanner) in

     }
}

最后我得到了这个问题的解决方案,因为安全区域。 ios 11 提供安全区域,因此如果您有 ios 10 支持的应用程序,则禁用安全区域。

解决此问题的另一种方法是设置部署目标 "iOS 10 及更高版本"

  1. 在Xcode
  2. 中打开xib
  3. 来自 tom 菜单 select 查看 -> 检查器 -> 文件
  4. Select “为构建”iOS 10及更高版本 in “Interface Builder 文档” 部分