eBay / NMessenger

A fast, lightweight messenger component built on AsyncDisplaykit and written in Swift
Other
2.42k stars 272 forks source link

Crash when attempt to send collectionView. #193

Open vandana26V opened 6 years ago

vandana26V commented 6 years ago

Below is the snippet of my code:

screen shot 2018-03-02 at 3 23 26 pm

let customView = ConvView.init().instanceFromNib() as! ConversationalUITableViewCell let uiN: UINib = UINib(nibName: self.cellReuseIdentifier, bundle: nil) customView.tableView?.register(uiN, forCellReuseIdentifier: self.cellReuseIdentifier)

  let convHeaderPrevView = ConversationWithPreviewUIView.init().instanceFromNib() as! ConversationWithPreviewTableViewCell

  convHeaderPrevView.label1?.text = "SomeText"
  convHeaderPrevView.label2?.text = "XYZ"
  convHeaderPrevView.label3?.text = "12345"

  self.headerView = convHeaderPrevView

  self.documentTableView = customView.tableView
  self.documentTableView.dataSource = self
  self.documentTableView.delegate = self

  self.documentTableView.rowHeight = UITableViewAutomaticDimension
  self.documentTableView.estimatedRowHeight =  50
  self.documentTableView.sectionHeaderHeight = UITableViewAutomaticDimension
  self.documentTableView.estimatedSectionHeaderHeight = 10
  self.documentTableView.sectionFooterHeight = 0

  self.documentTableView.reloadData()

  viewsArr.append(conversationView)
  viewsArr.append(conversationView)

  messengerView.addMessage(sendCollectionViewWithViews(viewsArr, numberOfRows: 1, isIncomingMessage: true), scrollsToMessage: true)
akuzminskyi commented 6 years ago

Looks like if CollectionViewContentNode will be initialized with public init(withCustomViews customViews: [UIView], andNumberOfRows rows:CGFloat, bubbleConfiguration: BubbleConfigurationProtocol? = nil) method, collectionNodesDataSource is nil and in open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets we use force unwrapping for this variable, and that's why we have the crash.

vandana26V commented 6 years ago

So what is the solution for this? Should I include collectionview datasource and delegate in my controller?