它给出了一个错误 UITableViewDataSource, UITableViewDelegate
“HomePageVCNEW”与协议(protocol)“UITableViewDelegate”的冗余一致性
import UIKit
class HomePageVCNEW: UITableViewController, UITableViewDataSource, UITableViewDelegate {
var arrayofCellData = [cellData]()
@IBOutlet var tableview: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
arrayofCellData = [cellData(cell: 1,DisplayNameText: "TOM",StatusSubtitleText: "Tom's subtitle",ProfileImage:#imageLiteral(resourceName: "mark1"),AccountTypeImage:#imageLiteral(resourceName: "icon-72x72"),MoreOptionsImage: #imageLiteral(resourceName: "ADD BUTTON CENTRED")),cellData(cell: 2,DisplayNameText: "Ben",StatusSubtitleText: "Ben's subtitle",ProfileImage:#imageLiteral(resourceName: "tom3"),AccountTypeImage:#imageLiteral(resourceName: "B icon 72x72"),MoreOptionsImage: #imageLiteral(resourceName: "ADD BUTTON CENTRED")),cellData(cell: 1,DisplayNameText: "liam",StatusSubtitleText: "liam's subtitle",ProfileImage:#imageLiteral(resourceName: "denis2"),AccountTypeImage:#imageLiteral(resourceName: "icon-72x72"),MoreOptionsImage: #imageLiteral(resourceName: "ADD BUTTON CENTRED"))]
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 0
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return arrayofCellData.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if
arrayofCellData[indexPath.row].cell == 1{
let cell = self.tableview.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
as! CustomCell
cell.ProfileImage.image = arrayofCellData[indexPath.row].ProfileImage
cell.MoreOptionsImage.image = arrayofCellData[indexPath.row].MoreOptionsImage
cell.AccountTypeImage.image = arrayofCellData[indexPath.row].AccountTypeImage
cell.DisplayNameLabel.text = arrayofCellData[indexPath.row].DisplayNameText
cell.SubtitleStatusLabel.text = arrayofCellData[indexPath.row].StatusSubtitleText
return cell
}else if arrayofCellData[indexPath.row].cell == 2{
let cell = self.tableview.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
as! CustomCell
cell.ProfileImage.image = arrayofCellData[indexPath.row].ProfileImage
cell.MoreOptionsImage.image = arrayofCellData[indexPath.row].MoreOptionsImage
cell.AccountTypeImage.image = arrayofCellData[indexPath.row].AccountTypeImage
cell.DisplayNameLabel.text = arrayofCellData[indexPath.row].DisplayNameText
cell.SubtitleStatusLabel.text = arrayofCellData[indexPath.row].StatusSubtitleText
return cell
}else{
let cell = self.tableview.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
as! CustomCell
cell.ProfileImage.image = arrayofCellData[indexPath.row].ProfileImage
cell.MoreOptionsImage.image = arrayofCellData[indexPath.row].MoreOptionsImage
cell.AccountTypeImage.image = arrayofCellData[indexPath.row].AccountTypeImage
cell.DisplayNameLabel.text = arrayofCellData[indexPath.row].DisplayNameText
cell.SubtitleStatusLabel.text = arrayofCellData[indexPath.row].StatusSubtitleText
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if arrayofCellData[indexPath.row].cell == 1{
return 49
}else if arrayofCellData[indexPath.row].cell == 2{
return 49
}else{
return 49
}
}
}
}//class
最佳答案
当一个类继承自 UITableViewController 时,它默认符合 UITableViewDataSource
和 UITableViewDelegate
,您无需指定它。尝试在 UITableViewController
UITableViewDataSource
和 UITableViewDelegate
关于 'HomePageVCNEW' 对协议(protocol) 'UITableViewDelegate' 的快速冗余一致性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44344020/