gpt4 book ai didi

ios - "Expected expression in list of expressions"

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:06:03 24 4
gpt4 key购买 nike

我正在尝试使用一些代码来制作一个使用 Xcode 7.3 和 Swift 2.2 的初学者应用程序,但我一直遇到同样的问题。我以前使用过类似的代码,但这行不通。出现的错误消息是“预期的‘,’分隔符”,当我修复它时,同样的消息一次又一次地出现。我还得到“表达式列表中的预期表达式”和“调用中参数‘action’缺少参数”。它们都是由同一行引起的

   button.addTarget(self, action: #selector(RatingControl.ratingButtonTapped(_:)), forControlEvents: .TouchDown)

这是代码

import UIKit

class RatingControl: UIView {

required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)

let button = UIButton(frame: CGRect(x: 0, y: 0, width: 44, height: 44))
button.backgroundColor = UIColor.redColor()
button.addTarget(self, action: #selector(RatingControl.ratingButtonTapped(_:)), forControlEvents: .TouchDown)
addSubview(button)
}

override func intrinsicContentSize() -> CGSize {
return CGSize(width: 240, height: 44)
}

func ratingButtonTapped(button: UIButton) {
print("Button pressed")
}
}

最佳答案

您需要清理项目。

Shift + + K

关于ios - "Expected expression in list of expressions",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36165674/

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