【发布时间】:2015-01-13 15:37:35
【问题描述】:
我有一个自定义 UIButton 类,我试图将它导入到我的项目中的 ViewController 类中,但我收到错误消息:'ViewController' 不符合协议 'OverrideButtonDelegate'"
这是自定义 UIButton 类的代码:
import Foundation
import UIKit
protocol OverrideButtonDelegate: NSObjectProtocol {
func overrideButtonDidStartPress(overrideButton: OverrideButton)
func overrideButtonDidEndPress(overrideButton: OverrideButton)
}
class OverrideButton: UIButton {
var delegate: OverrideButtonDelegate?
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
delegate?.overrideButtonDidStartPress(self)
}
override func touchesEnded(touches: NSSet, withEvent event: UIEvent) {
delegate?.overrideButtonDidEndPress(self)
}
}
这是来自 ViewController 的代码,其中我收到错误消息“类型 'ViewController' 不符合协议 'OverrideButtonDelegate'”
class ViewController: UIViewController, OverrideButtonDelegate {
【问题讨论】:
标签: ios iphone swift uiviewcontroller uibutton