私はTableViewにCollectionViewを持っています。すべてが大丈夫です。 ?行:私は別のViewControllerに自分のセルを移動したいとき、私はiOS SwiftカスタムセルNavigationController
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath){
let storyboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle())
let bookView: BookSingleController = storyboard.instantiateViewControllerWithIdentifier("BookSingle") as! BookSingleController
self.navigationController?.pushViewController(bookView, animated: true)
bookView.bookID = "\(self.books[indexPath.row].id)"
print(self.books[indexPath.row].id)
}
のXcodeは私に(真アニメーションbookView、)self.navigationController .pushViewController上のエラーを示し、エラーました。これはエラーの説明です:
Value of 'RelatedBookTableViewCell' has no member 'navigationController'
RelatedBookTableViewCellは私のカスタムセルクラスです:
class RelatedBookTableViewCell: UITableViewCell, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout
私の問題はありますか?
ありがとうございました。
、UICollectionVi ewはUITableViewに、新しいView Controllerをプッシュする必要があることをUINavigationController(UIViewControllerのトラフ)に通知します。 – Larme
セルは、他のセルのデータソースまたはデリゲートとして機能しません。これはコントローラの仕事です。この設定を保持したい場合は、セル選択を 'UIViewController'インスタンスに委譲します。セルには、ナビゲーションコントローラのプロパティはありません。 – donnywals
@Larme私はRelatedBookTableViewCellクラスでUINavigationControllerDelegateを使用しますが、エラーは依然として存在します。 – MohammadReza