Collection View の labelに他クラスのtextを入れたいです。
初めに他クラス( PostViewController)を入れるために
var postViewController = PostViewController()
と書きました。
他クラス(PostViewController)のpostTextViewをこのクラスのラベルに入れたくて
以下の**のように
label.text = postViewController.postTextView as? String
と書きました。
すると、[<UICollectionViewCell 0x7faffd5c0fc0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key titleLavel.'
というエラーが出ました。
他クラスのtextをCollection Viewのlabelに入れるにはどうしたらよいでしょうか。
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) let photoImageView = cell.viewWithTag(1) as! UIImageView let photoImagePath = posts[indexPath.row].imageUrl photoImageView.kf.setImage(with: URL(string: photoImagePath)) let label = cell.contentView.viewWithTag(2) as! UILabel ** label.text = postViewController.postTextView as? String** return cell }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/08/16 08:38