gpt4 book ai didi

swift - 在 Swift 中启动 View 的奇怪错误

转载 作者:搜寻专家 更新时间:2023-11-01 06:24:47 24 4
gpt4 key购买 nike

我有这些行来初始化一个 View

let rect : CGRect = CGRectMake(0,0,320,100)
var vista : UIView = init(frame: rect)

但是如果我像这样将 rect 声明转置到第二行

var vista : UIView = init(frame: CGRectMake(0,0,320,100))

它给我这个错误:

enter image description here

为什么?

最佳答案

你没有正确使用初始化器,正确的方法是

var vista : UIView = UIView(frame:CGRectMake(0,0,320,100))

关于swift - 在 Swift 中启动 View 的奇怪错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24111632/

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