编译器无法在合理的时间内对该表达式进行类型检查;尝试将表达式分解为不同的子表达式
//检查窗口框架中的弹出窗口
let spaceFromLeftSide = cutOutViewX.constant + cutOutViewWidth.constant/2 - (options.textWidth + padding*2)/2
let spaceFromRightSide = cutOutViewX.constant + cutOutViewWidth.constant/2 + (options.textWidth + padding*2)/2
问题是由于复杂的表达式,编译器无法及时计算值。您需要将这些表达式分解为子表达式,如下所示:
let cutOutValue = cutOutViewX.constant + cutOutViewWidth.constant/2
let optionsValue = (options.textWidth + padding*2)/2
let spaceFromLeftSide = cutOutValue - optionsValue
let spaceFromRightSide = cutOutValue + optionsValue
这种类型的中断不仅对编译时有帮助,而且在调试时也很有帮助,您可以在其中检查变量具有的当前值。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句