同じCollectionviewcellに2つのtableviewがあります。私は、アプリケーションを実行すると、それはテーブルビューのcellforrowatindexpathにクラッシュし、言う:「致命的なエラー:オプションの値をアンラップしながら、予想外にnilを見つけ、」これは、tableviewのcellforrowatindexpathでクラッシュする: "致命的なエラー:予期せず、オプション値をアンラッピングしている間にnilが見つかりました"
私のコードのいくつかの下に見つけてください -
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) ->
UITableViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier:
reuseIdentifier, for: indexPathOfCollectionView as IndexPath) as!
MyCustomCollectionViewCell
if(tableView == cell.graphTableView){
let cell:CustomGraphTableViewCell =
tableView.dequeueReusableCell(withIdentifier: "CustomGraphTableViewCell") as!
CustomGraphTableViewCell
return cell
}
else
{
let cell:MyCustomTableViewCell =
tableView.dequeueReusableCell(withIdentifier: "MyCustomTableViewCell") as!
MyCustomTableViewCell
cell.nameLabel.text = namesArray[indexPath.row]
return cell
}
}
缶だれでもしてください解決策を提案する。なぜそれが起こっているのでしょうか、同じものに対する解決策は何でしょうか?テーブルビューUICollectionViewCell
で
あなたがで 'CollectionViewCell''をデキューすることはできませんがTableView 'cellForRowAt'メソッド。 –
ここで強制的にアンラップしてください!あなたのすべてのセルをチェックしてください。なぜなら、今度はその無限 –
@NiravDです。そこにコレクションビューのセルを宣言しなければ、どのようにテーブルビューにアクセスできますか? –