Я получаю 2 ошибки.
Первое, что меня смущает, потому что все находится внутри {}, поэтому я не уверен, где я ошибаюсь.
"Тип" StoriesViewController "не соответствует протоколу Исправление щелчка «UITableViewDataSource» добавляет:
прикол c tableView (_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {<# code #>}
и 2-я ошибка
Неоднозначное использование 'dequeueReusableCellWithIdentifier
Я присвоил ячейке таблицы идентификатор "storyCell" из основной раскадровки
Полный код:
// creating a custom color
extension UIColor {
static var darkmodeGray = UIColor.init(red: 41/255, green: 42/255, blue: 47/255, alpha: 1)
}
class StoriesViewController: UIViewController,UITableViewDataSource,UITableViewDelegate {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
<#code#>
}
@IBOutlet weak var tableView: UITableView!
let storySelection = [("WeekOne"),("WeekTwo"),("WeekThree"),("WeekFour"),("WeekFive"),("WeekSix")]
let storySelectionImages = [UIImage(named: "WeekOne"), UIImage(named: "WeekTwo"), UIImage(named: "WeekThree"), UIImage(named: "WeekFour"), UIImage(named: "WeekFive"), UIImage(named: "WeekSix")]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
self.view.backgroundColor = UIColor .darkmodeGray
}
//Part One
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
//Part Two
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return storySelection.count
}
//Part Three
private func tableView(tableView :UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell=tableView.dequeueReusableCellWithIdentifier("storyCell", forIndexPath: IndexPath) as! TableViewCell
cell.CoverArt.image=self.storySelectionImages[indexPath .row]
return cell
}
}