import UIKit
class exploreViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var searchBar: UISearchBar!
@IBOutlet weak var exploreTableView: UITableView!
var CELLHEIGHT = 200
var SECTIONHEADER = "SECTIONHEADER"
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
exploreTableView.delegate = self
exploreTableView.dataSource = self
exploreTableView.register(UINib(nibName: "answerCell", bundle: nil), forCellReuseIdentifier: "cell1")
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 2
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return SECTIONHEADER
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 2
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = self.exploreTableView.dequeueReusableCell(withIdentifier: "cell1", for: indexPath) as! answerCell
cell.name.text = "222222"
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return CGFloat(CELLHEIGHT)
}
}
Мой numberOfSectionsInTableView
никогда не звонил, и я не могу получить 2 раздела.numberOfSectionsInTableView не работает
Потому что это не имя метода. Его имя - 'numberOfSections (in:)'. – matt
@matt 'numberOfSections (in: tableView)'? –
@OnurTuna Различать имя из декларации. – matt