【发布时间】:2018-01-25 05:34:16
【问题描述】:
我正在检索一个数组元素,但所有元素都在单个单元格中检索,而不是每个新单元格中的每个元素。我希望PDFList 数组的每个元素都应该在每个单元格中。
这是我得到的
这是我迄今为止为获取数据所做的工作:
import UIKit
@available(iOS 11.0, *)
class PDFListViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
var PDFList = [String]()
@IBOutlet weak var PDFListTable: UITableView!
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return PDFList.count
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = PDFListTable.dequeueReusableCell(withIdentifier: "PDFCell") as! PDFTableViewCell
cell.pdfLabel.text = PDFList[indexPath.row]
return cell
}
override func viewDidLoad() {
super.viewDidLoad()
PDFListTable.delegate = self
PDFListTable.dataSource = self
PDFList = ["Form title 1, Form title 2, Form title 3,Form title 4, Form title 5, Form title 6,Form title 7, Form title 8, Form title 9,Form title 10, Form title 11, Form title 12"]
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
【问题讨论】:
-
请遵守标准。变量和函数名称以小写字母开头。类和结构名称以大写字母开头。
标签: ios arrays swift uitableview tableview