私は、viewViewrollerをcollectionViewからプログラムで(ストーリーボードなしで)表示するのに問題があります。私はこれがかなり簡単だと思うだろうが、私はいくつかの困難を抱えているが、これは私がいくらか新しいことを迅速にしているからだ。私はcollectionViewCellsがデフォルトでデリゲートではないと思うので、私はcollectionViewクラスでdidSelectItemAtを実装しようとしましたが、まだ運がありません。セルのタップで、私は印刷の声明を受けています、ちょうどショーセグを持っていません。下記のcollectionViewCellコードをご覧ください。viewViewController from storyboardsなし
// collectionViewCell class
class PlanningCell: BaseCell, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {
lazy var collectionView: UICollectionView = {
let layout = UICollectionViewFlowLayout()
let cv = UICollectionView(frame: .zero, collectionViewLayout: layout)
cv.dataSource = self
cv.delegate = self
return cv
}()
//collectionViewCell variables
var plannedPlaces = [CurrentPlanner]()
let cellId = "cellId"
var basePlanningCell: BasePlanningCell!
override func setupViews() {
super.setupViews()
addSubview(collectionView)
collectionView.register(BasePlanningCell.self, forCellWithReuseIdentifier: cellId)
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return plannedPlaces.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cellId", for: indexPath) as! BasePlanningCell
cell.currentPlanner = plannedPlaces[indexPath.item]
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
print("did tap")
let plannersDetailVC = PlanningPlaceDetailsVC()
plannersDetailVC.navigationTitle = plannedPlaces[(indexPath.row)].planningPlace
// below I am receiving the use of unresolved identifier "show" error
show(plannersDetailVC, sender: self)
}
}
ありがとうございましたが、今、私にエラーメッセージ "PlanningCellの値はタイプメンバ 'present'がありません" – user3708224
@ user3708224更新された私の答え –
ありがとう、ありがとう。私はそれらのオプションを調べます。 – user3708224