简体   繁体   English

对象与协议的冗余一致性

[英]Redundant conformance of Object to Protocol

I have this error Redundant conformance of 'AnyView' to protocol 'Pressable' when attempt to run the below code.尝试运行以下代码时,出现Redundant conformance of 'AnyView' to protocol 'Pressable'错误。 Could anyone shows the error or any other way to perform the same login with protocols.任何人都可以显示错误或使用协议执行相同登录的任何其他方式。

class AnyView: UIView, Pressable {

}

// MARK: - Pressable

protocol Pressable: UIView {

}

extension UIView: Pressable {
    // touchesBegan
    override open func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        super.touchesBegan(touches, with: event)
        scaleAnimation(value: 0.8)
    }
}

You simply need to get rid to the AnyView conformance to Pressable , since its superclass, UIView already conforms to Pressable .你只需要摆脱对AnyView一致性,以Pressable ,因为它的超UIView已符合Pressable

class AnyView: UIView {

}

// MARK: - Pressable

protocol Pressable: UIView {

}

extension UIView: Pressable {
    // touchesBegan
    override open func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        super.touchesBegan(touches, with: event)
        scaleAnimation(value: 0.8)
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ChatViewController与协议的冗余一致性 - Redundant conformance of the ChatViewController to protocol “ InboxTableViewController”与协议“ UITableViewDataSource”的冗余一致性 - Redundant conformance of 'InboxTableViewController' to protocol 'UITableViewDataSource' Swift:Viewcontroller与协议UIGestureRecognizerDelegate的冗余一致性 - Swift : Redundant conformance of Viewcontroller to protocol UIGestureRecognizerDelegate 错误:“ ViewController”与扩展协议的冗余一致性 - Error: Redundant conformance of 'ViewController' to protocol with extension Xcode 7 beta 5 Swift 2冗余符合协议错误 - Xcode 7 beta 5 Swift 2 redundant conformance to protocol error “ CLLocationCoordinate2D”与协议“可解码” /“可编码”的冗余一致性 - Redundant conformance of 'CLLocationCoordinate2D' to protocol 'decodable'/'encodable' 如何在swift中解决错误“viewController与协议UIScrollViewDelegate的冗余一致性? - How to solve the error "Redundant conformance of viewController to protocol UIScrollViewDelegate in swift? 如何将 Class object 转换为符合协议 - How to cast Class object to conformance witih protocol 快速冗余一致性 - Swift Redundant conformance 在iOS Swift中将FBSDKCore更新为5.6.0后,&#39;ViewController&#39;与协议&#39;SharingDelegate&#39;的冗余一致性 - Redundant conformance of 'ViewController' to protocol 'SharingDelegate' after updating the FBSDKCore to 5.6.0 in iOS Swift
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM