Шаг - 1: Создайте UItableView на вашей доске рассказов. - Источник данных, делегат
Шаг - 2: импорт - UITableViewDelegate, UITableViewDataSource
Шаг - 3: Методы реализации
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return self.arr.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCell(withIdentifier: "MyCell") as! MyCell
cell.selectionStyle = .none
let dictData = self.arr[indexPath.row] as? NSMutableDictionary
let image = dictData?.object(forKey: "image") as! String
cell.lblSchoolName?.text = dictData?.object(forKey: "name") as? String
cell.lblSchoolAddress?.text = dictData?.object(forKey: "address") as? String
cell.img?.sd_setImage(with: URL(string: image), placeholderImage: UIImage(named: "splash screen-test-compress.jpg"), options: [.continueInBackground,.lowPriority], completed: {(image,error,cacheType,url) in
if error == nil
{
cell.img?.image = image
}
else
{
cell.img?.image = UIImage(named: "splash screen-test-compress.jpg")
}
})
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
{
let dictData = self.arrAll[indexPath.row] as! NSMutableDictionary
let AllEvent_VC = self.storyboard?.instantiateViewController(withIdentifier: "AllEvent_VC") as! AllEvent_VC
let strSlug = String(dictData.object(forKey: "slug") as! String)
AllEvent_VC.strSlug = strSlug
self.navigationController?.pushViewController(AllEvent_VC, animated: true)
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 100
}
// self.TableViewHeight.constant = CGFloat (self.arrAllSchoolByDistData.count * 100)
//self.view.updateConstraintsIfNeeded()