[ad_1]
I’m making an attempt to create UITableview with cells, an identical to the iPhone settings screenshot.
It’s a part of my homework so i’ve to do all of it in UITableview.
that is what I did with my code, however all the things is pink and full with errors. I attempted to do it following the samples from classes but it surely kinda seems all fallacious.
Please, assist me perceive how this factor works and what’s fallacious.
import UIKit
struct Traces{
var picture: [UIImage] = []
var title: [String] = []
}
class Titles {
static func titles() -> [Lines]{
return [
Lines(image: UIImage[ systemName: "airplane" ,"wifi.square.fill", "bitcoinsign.circle.fill", "iphone.homebutton.radiowaves.left.and.right", "personalhotpot" ], title: ["Авиарежим" , "Wi-fi", "Bluetooth", "Сотовая связь", "Режим модема"]),
Traces(picture: UIImage[ systemName: "bell.badge.fill" ,"speaker.wave.3.fill", "moon.fill", "iphone.homebutton.radiowaves.left.and.right", "clock.fill" ], title: ["Уведомления", "Звуки,тактильные сигналы", "Не беспокоить", "Экранное время"]),
Traces(picture: UIImage[ systemName: "gear" ,"switch.2", "display" ] , title: ["Общие", " Control Centre", "Экран и яркость"])
]
}
}
class SecondTableViewController: UITableViewController {
var traces = Titles.titles()
override func viewDidLoad() {
tremendous.viewDidLoad()
}
}
extension SecondTableViewController: UITableViewDataSource, UITableViewDelegate{
func numberOfSections(in tableView: UITableView) -> Int {
return titles.rely
}
func tableView(_ tableView: UITableView, numberOfRowsInSection part: Int) -> Int {
return titles[section].title.rely
}
override func tableView(_ tableView: UITableView, viewForHeaderInSection part: Int) -> UIView? {
let cell = tableView.dequeueReusableCell(withIdentifier: "SectionCell") as! TableViewCell
let title = titles[section]
cell.picture = Traces.picture
cell.titleLabel.textual content = Traces.title
return cell
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "SecondTableViewCell") as! TableViewCell
let identify = titles[indexPath.section].title[indexPath.row]
cell.picture = Traces.picture
cell.titleLabel.textual content = Traces.title
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
}
}
Thanks!
[ad_2]
