sections = [
Section.init(name: "SelectFromOptions", items: dealnameArray),
Section(name: "merchant Details", items:merchantdetailsArray),
Section(name: "How to use deals", items: ["iPhone 6s", "iPhone 6", "iPhone SE", "Accessories"]),
Section(name: "things to remember", items: ["exchange for cash not allowed"]),
Section(name: "Cancelation policy", items: ["Once bought cannot exchange"]),
Section(name: "what you get", items: ["Capacity buliding courses"])
]
func numberOfSections(in tableView: UITableView) -> Int {
return sections.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return sections[section].items.count
}
//
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as UITableViewCell? ?? UITableViewCell(style: .default, reuseIdentifier: "cell")
cell.textLabel?.numberOfLines = 0
cell.textLabel?.text = sections[(indexPath as NSIndexPath).section].items[(indexPath as NSIndexPath).row]
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return sections[(indexPath as NSIndexPath).section].collapsed! ? 0 : 44.0
}
我想在每个部分中添加不同的标签和按钮,有可能吗?通过使用bpove代码的所有细胞中只包含标签,我想在我的firt部分如何在tableview的第一部分添加按钮和标签,第二部分只包含标签
你能解释一下吗? – udaykumar40
通过使用我的代码 – udaykumar40