テーブルに2つの異なるセルを表示する必要があります。プロトタイプをテーブルに設定して試しました。まだそれはPrototype table cells must have reuse identifiers
警告を表示しています。UITableViewで2つのカスタマイズされたセルを表示する方法
この警告を解決するには、誰かを案内してください。ストーリーボードで UITableview with more than One Custom Cells with Swift
テーブルに2つの異なるセルを表示する必要があります。プロトタイプをテーブルに設定して試しました。まだそれはPrototype table cells must have reuse identifiers
警告を表示しています。UITableViewで2つのカスタマイズされたセルを表示する方法
この警告を解決するには、誰かを案内してください。ストーリーボードで UITableview with more than One Custom Cells with Swift
はあなたがこの
のように特定のセルのための特定の識別子を使用する必要がcellForRowAtIndexPath
に
そして、下の画像のような細胞のための識別子を定義する必要があります。
は、このリンクをたどっ
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
if indexPath.row == 0 {
let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Identifier1")
//set the data here
return cell
}
else if indexPath.row == 1 {
let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Identifier2")
//set the data here
return cell
}
}
プロトタイプセルの両方にReuse Identifier
を設定する必要があります。次に、cellForItemAtIndexPath
メソッドでは、指定されたindexPathに基づいて対応するReuse Identifier
を使用してセルをデキューする必要があります。代わりに、2つの異なるビューで一つのセルを使用することができる2個の異なる細胞の
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableView {
switch indexPath.section {
case 0:
return tableView.dequeueReusableCellWithIdentifier("CustomCell1", forIndexPath: indexPath)
case 1:
return tableView.dequeueReusableCellWithIdentifier("CustomCell2", forIndexPath: indexPath)
break:
return UITableViewCell()
}
}
。 –
@SaurabhPrajapatiそうですね。しかし、私はプロトタイプを使って間違いを知りたいと思っています。 – Dee