0
我有一個TableView
,我已經爲該TableView
創建了自定義單元格,帶有圖像,標籤..等等,但是我希望一個單元格與其他單元格不同,從後端獲取他們的數據)。 那麼如何在同一個TableView
中創建2種不同類型的單元格,以及如何安排它們,例如在2個其他單元格之間放置1種單元格?UITableView與3個自定義單元,但1個不同
編輯:我的UITableView類:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let myCell: CellTableViewCell = tableView.dequeueReusableCellWithIdentifier("myCell", forIndexPath: indexPath) as! CellTableViewCell
let otherCell: OtherCellTableViewCell = tableView.dequeueReusableCellWithIdentifier("otherCell", forIndexPath: indexPath) as! OtherCellTableViewCell
// Configure the cell...
return myCell
}
我已經有一個自定義單元格「的tableView:的cellForRowAtIndexPath:」如果我加了一個又一個,其中一個將被退回?檢查OP。 – Abdou023
你得到了你指定的reuseIdentifier。現在它是具有「myCell」標識符的那個。給其他單元格一個不同的標識符,如「myOtherCell」。在選擇單元格時,可以在Interface Builder的屬性窗格中指定它。 –
檢查OP,我編輯了該功能,但現在它表現得很奇怪。當我返回一個單元格時,另一個單元格顯示出來,如果我點擊它,它會變成另一個單元格。問題是我只能返回其中之一。 – Abdou023