とのscrollToBottom
関数がUIScrollView
ありUITableView
ます。問題は、それらがエラーで互いに競合していることです。Declarations in extensions cannot override yet
これは私が持っているものです:
extension UIScrollView {
func scrollToBottom(animated: Bool = true) {
...
}
}
extension UITableView {
func scrollToBottom(animated: Bool = true) {
...
}
}
からUITableView
継承しているのでUIScrollView
、これを行うことはできません。どうすればこれを達成できますか?
プロトコルScrollableToBottom
を作成し、そこでメソッドを定義します。
protocol ScrollableToBottom {
func scrollToBottom(animated: Bool)
}
それを作成UIScrollView
してUITableView
継承します:
extension UIScrollView: ScrollableToBottom { }
extension UITableView: ScrollableToBottom { }
次に、プロトコル制約Self
を特定のクラスに拡張する必要があります。
extension ScrollableToBottom where Self: UIScrollView {
func scrollToBottom(animated: Bool = true) {
}
}
extension ScrollableToBottom where Self: UITableView {
func scrollToBottom(animated: Bool = true) {
}
}
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加