我只是試圖在我設置的Smiles數組中顯示名稱的tableview。我需要將我的單元類「ClubCell」聲明爲擴展到UITableViewCell,我將如何去做這件事?聲明我的CellClass擴展到UITableViewCell?
class SmileClub: UITableViewController {
var Smiles: [String] = ["Price Garrett", "Michael Bishop", "Tom Kollross", "Cody Crawford", "Ethan Bernath", "Alex Mlynarz", "Ryan Murphy", "Kelly Murphy", "Ryan Roshan", "Sean Ko"]
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> ClubCell
{
let cell: ClubCell = tableView.dequeueReusableCellWithIdentifier("ClubCell") as! ClubCell!
cell.Name.text = self.Smiles[indexPath.row] as String
return cell
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.Smiles.count
}
爲什麼您只是完全改變了您的問題?不要這樣做。它將現有的答案留在不好的地方。我只是說你應該在你的問題中添加一行,而不是刪除原始問題的詳細信息。 – rmaddy
順便說一句 - 查看我更新的答案。僅供參考 - 如果您不知道如何在Swift中擴展課程,那麼您應該回到Swift書籍並研究基礎知識以供審閱。 – rmaddy