gpt4 book ai didi

Swift 3 init - 意外错误

转载 作者:行者123 更新时间:2023-11-30 12:56:15 25 4
gpt4 key购买 nike

在我认为是一个简单的子类中,我似乎不太明白这个问题。

此错误消息有任何意义吗?

'super.init' cannot be called outside of an initializer

enter image description here

或者,

enter image description here

SKPhoto 已声明开放,以下是父类(super class)的可用初始化:

// MARK: - SKPhoto
open class SKPhoto: NSObject, SKPhotoProtocol {

open var underlyingImage: UIImage!
open var photoURL: String!
open var contentMode: UIViewContentMode = .scaleAspectFill
open var shouldCachePhotoURLImage: Bool = false
open var caption: String!
open var index: Int = 0

override init() {
super.init()
}

convenience init(image: UIImage) {
self.init()
underlyingImage = image
}

convenience init(url: String) {
self.init()
photoURL = url
}

convenience init(url: String, holder: UIImage?) {
self.init()
photoURL = url
underlyingImage = holder
}

我实在无法解决这个问题!

最佳答案

SKPhoto 类似乎有问题;它尚未开放其 init 方法,因此您无法在子类中重写它们;

https://github.com/suzuki-0000/SKPhotoBrowser/blob/swift3/SKPhotoBrowser/SKPhoto.swift

如果您确实想使用它,您应该 fork 该存储库并进行适当的更改,然后就可以使用它。

关于Swift 3 init - 意外错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40366321/

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