質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Xcode

Xcodeはソフトウェア開発のための、Appleの統合開発環境です。Mac OSXに付随するかたちで配布されています。

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

Q&A

解決済

1回答

172閲覧

Use of unresolved identifier 'Init'

ntntnt_ntntnt

総合スコア13

Xcode

Xcodeはソフトウェア開発のための、Appleの統合開発環境です。Mac OSXに付随するかたちで配布されています。

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

0グッド

0クリップ

投稿2018/06/01 04:34

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}

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

fuzzball

2018/06/01 05:11

ビルドはしてみましたか?ビルドしてもエラーが消えないのでしょうか?
ntntnt_ntntnt

2018/06/01 05:14

そうですね、消えないです。
fuzzball

2018/06/01 05:26

ワークスペースを開いてますか?
fuzzball

2018/06/01 05:53

インストールしたFoldingCellのバージョンは?
ntntnt_ntntnt

2018/06/01 06:37

Githubから追加していないファイルConfigurationBlock.swiftがあり、そこにInitが宣言されていました。このファイルから、また新しいエラーとしてAttribute can only be applied to types, not declarationsが表示されたのですが直し方がわかりません。よろしければ教えて頂いてもいいでしょうか?
guest

回答1

0

自己解決

ConfigurationBlock.swiftというファイルを忘れていて、このファイルの中にInitが宣言されていました。

投稿2018/06/01 06:43

ntntnt_ntntnt

総合スコア13

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問