私は1つのオブジェクトの異なる情報を表示するためにunclickable tableViewを使用しています。 この情報では、マップに配置した場所、オブジェクトに場所がある場合、リンクがあるリストがある場合、小さな説明の場合は複数の行ラベルなど、異なるカスタムセルタイプがあります。これまでのところは良い複数のカスタムセルの変数の使用
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
if indexPath.row == 0 {
let cell: mapCell = tableView.dequeueReusableCellWithIdentifier("mapCell") as! MapCell
return cell
} else if indexPath.row == 1 {
let cell: textCell = tableView.dequeueReusableCellWithIdentifier("textCell") as! TextCell
return cell
} else if indexPath.row == 2 {
let cell: listCell = tableView.dequeueReusableCellWithIdentifier("listCell") as! ListCell
return cell
}
}
、すべての作業罰金:
は、私がこのセルを管理します。私の問題は、すべてのオブジェクトが地図を必要としているわけではなく、いくつかはテキストとリストだけが必要であり、他のオブジェクトはマップやリスト、その他すべてが必要です。私は条件がある場合、私のtableViewいくつかのセルをスキップしたい。
私は、私のtableViewのセルの数を変更するためのシンボリックな配列を作ることができますが、私は特定のセルではなく、私のtableViewの最後から削除することができます。
私はこのような何かを行うことができるように私のアイデアの一つは、多分、0または1の高さで、空のセルを生成することです:がない場合、私は知らない
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
if indexPath.row == 0 {
if mapCellNeeded {
let cell: mapCell = tableView.dequeueReusableCellWithIdentifier("mapCell") as! mapCell
} else {
let cell: emptyCell = tableView.dequeueReusableCellWithIdentifier("emptyCell") as! EmptyCell
}
return cell
} else if indexPath.row == 1 {
...
}...
}
プット効率的な方法です。あなたたちが私を助けてくれることを願っています。
必要なセル情報を保持するオブジェクトの配列を作成し、空のセルをその配列内にあるものと同じ数だけ作成しないでください。空のセルを作って、それがまったく必要ないことを意味するならば、 –