Ios CollectionView cellForItemAt indexPath不显示单元格,但单元格';他的观点是否定的

Ios CollectionView cellForItemAt indexPath不显示单元格,但单元格';他的观点是否定的,ios,swift3,uicollectionviewcell,Ios,Swift3,Uicollectionviewcell,视图插座与单元连接 在展开可选值时,抛出意外地发现了nil首先使用标识符创建自定义单元格的xib 使用前先注册单元格,使用以下示例 guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "identifier", for: indexPath) as? MYVerticalCell else { fatalError("Couldn't deque `Vertical Cell`") } cell.

视图插座与单元连接


在展开可选值时,抛出意外地发现了nil

首先使用标识符创建自定义单元格的xib

使用前先注册单元格,使用以下示例

guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "identifier", for: indexPath) as? MYVerticalCell else {
  fatalError("Couldn't deque `Vertical Cell`")
}

cell.view.backgroundColor = .black
return cell
然后在“func tableView(u tableView:UITableView,cellForRowAt indexath:indexPath)->UITableViewCell”中使用


首先使用标识符创建自定义单元格的xib

使用前先注册单元格,使用以下示例

guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "identifier", for: indexPath) as? MYVerticalCell else {
  fatalError("Couldn't deque `Vertical Cell`")
}

cell.view.backgroundColor = .black
return cell
然后在“func tableView(u tableView:UITableView,cellForRowAt indexath:indexPath)->UITableViewCell”中使用


代码在哪一行崩溃?@Mansi Shah使用control+k格式化代码。@Mansi Shah自定义单元格类中是否有UIView?是否使用viewDidLoad中的某些内容注册单元格?只是检查一下。您确定是垂直调用而不是VerticalCell吗?检查outlet view是否与MYVerticalCell正确连接。代码在哪一行崩溃?@Mansi Shah使用control+k格式化您的代码。@Mansi Shah自定义单元格类中是否有UIView?您是否使用viewDidLoad中的某些内容注册了您的单元格?请检查。你确定是垂直调用而不是垂直单元格吗?检查outlet view是否与MYVerticalCell正确连接。我的问题是UICollectionView,我已经完成了相同的注册,并且也使用了collection view单元格出列。我的问题是UICollectionView,我已经完成了相同的注册,也使用了collection view单元格出列。
var cell = tableView.dequeueReusableCell(withIdentifier: "custCell") as? CustCell

if (cell == nil) {
    cell = CustCell(style: UITableViewCellStyle.default, reuseIdentifier: "custCell"
}