gpt4 book ai didi

ios - 一个错误? UIView 扩展中的属性

转载 作者:行者123 更新时间:2023-11-28 07:17:46 25 4
gpt4 key购买 nike

我为 UIView 创建了一个扩展:

import UIKit

extension UIView {

var frameHeight : CGFloat {

get {
return self.frame.size.height
}
set(newHeight) {
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y,self.frame.size.width, newHeight)
}
}
}

然后我在我自己的 UIView 的方法中使用了这个:

class MyView: UIView {

func updateHeight() {

self.frameHeight = 200.0
setNeedsDisplay()
}
}

编译错误:

While emitting IR SIL function @_TFC15Simple15MyView10updateHeightfS0_FT_T_ for 'updateHeight' at /MyView.swift:88:5
<unknown>:0: error: unable to execute command: Segmentation fault: 11
<unknown>:0: error: swift frontend command failed due to signal (use -v to see invocation)
Command /Applications/Xcode6-Beta3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift failed with exit code 254

当我注释掉 self.frameHeight = 200.0 行时,编译错误消失了。

这是一个错误吗?还是我做错了什么?谢谢。

最佳答案

当我在 Playground 中运行它时它起作用了,我没有看到任何明显的错误。

在任何情况下,即使它是您代码中的错误,它也不应该使编译器崩溃。我觉得你应该create a bug report与 Apple。

关于ios - 一个错误? UIView 扩展中的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24701871/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com