Swift4でFoldingCellというライブラリを使いたいのですが、Githubソースコードをそのままコピーしてもエラーが出てきます。エラーの内容はUse of unresolved identifier 'Init'
というエラーなのですが、どう直せば良いのかわかりません。
Podfileはすでにインストール済みです。よろしくお願いします。
Swift
1import UIKit 2import FoldingCell 3import EasyPeasy 4 5class DemoFoldingCell: FoldingCell { 6 7 override init(style: UITableViewCellStyle, reuseIdentifier: String?) { 8 super.init(style: style, reuseIdentifier: reuseIdentifier) 9 10 containerView = createContainerView() 11 foregroundView = createForegroundView() 12 13 // スーパークラスメソッドがビューを構成 14 commonInit() 15 } 16 17 required init?(coder aDecoder: NSCoder) { 18 fatalError("init(coder:) has not been implemented") 19 } 20 21 override func animationDuration(_ itemIndex: NSInteger, type: AnimationType) -> TimeInterval { 22 23 // durationcountとitemcountは等しい 24 let durations = [0.33, 0.26, 0.26] // 各ビューのアニメーションのタイミング 25 return durations[itemIndex] 26 } 27} 28 29// MARK: Configure 30extension DemoFoldingCell { 31 32 private func createForegroundView() -> RotatedView { 33 let foregroundView = Init(RotatedView(frame: .zero))//Use of unresolved identifier 'Init' 34 { 35 $0.backgroundColor = .redColor() 36 $0.translatesAutoresizingMaskIntoConstraints = false 37 } 38 39 contentView.addSubview(foregroundView) 40 41 // 制約 42 foregroundView <- [ 43 Height(75), 44 Left(8), 45 Right(8), 46 ] 47 48 // 識別子を追加する 49 let top = (foregroundView <- [Top(8)]).first 50 top?.identifier = "ForegroundViewTop" 51 52 foregroundView.layoutIfNeeded() 53 54 return foregroundView 55 } 56 57 private func createContainerView() -> UIView { 58 let containerView = Init(UIView(frame: .zero))//Use of unresolved identifier 'Init' 59 { 60 $0.backgroundColor = .greenColor() 61 $0.translatesAutoresizingMaskIntoConstraints = false 62 } 63 64 contentView.addSubview(containerView) 65 66 // add constraints 67 containerView <- [ 68 Height(CGFloat(75 * itemCount)), 69 Left(8), 70 Right(8), 71 ] 72 73 // add identifier 74 let top = (containerView <- [Top(8)]).first 75 top?.identifier = "ContainerViewTop" 76 77 containerView.layoutIfNeeded() 78 79 return containerView 80 } 81}
「Githubソースコード」というのが古いものではないのでしょうか?最新のリポジトリ上にそのようなコードは見つかりませんでした。( https://github.com/0ber/Folding-cell-programmatically/tree/master/FoldingCellProgrammatically ここにはそれっぽいコードが見つかりましたが二年前のコードです)
Githubから追加していないファイルConfigurationBlock.swiftがあり、そこにInitが宣言されていました。このファイルから、また新しいエラーとしてAttribute can only be applied to types, not declarationsが表示されたのですが直し方がわかりません。よろしければ教えて頂いてもいいでしょうか?
回答1件
あなたの回答
tips
プレビュー