class InfotableViewController: UIViewController,UITableViewDelegate,UITableViewDataSource{
let myActivityIndicator = UIActivityIndicatorView()
var name = [String]()
var imagearray=[UIImage]()
@IBOutlet weak var table: UITableView!
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 5
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 150
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = table.dequeueReusableCell(withIdentifier: "cell") as! profileTableViewCell
cell.tableimage.image = nil;
cell.tableimage.image = imagearray[indexPath.row] as! UIImage
cell.tablelabel.text = name[indexPath.row] as! String
self.myActivityIndicator.stopAnimating()
return cell
}
2 回答
2
你应该做这个,
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 100
}
和这个,
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = table.dequeueReusableCell(withIdentifier: "cell") as! profileTableViewCell
cell.tableimage.image = nil;
let index = indexPath.row%5
cell.tableimage.image = imagearray[index] as! UIImage
cell.tablelabel.text = name[indexPath.row] as! String
self.myActivityIndicator.stopAnimating()
return cell
}
于 2018-05-23T07:29:03.853 回答
0
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell1")
cell?.textLabel?.text = (list1[indexPath.row % list1.count]
cell?.imageView?.image = (list1[indexPath.row % list1.count]
return cell!
}
于 2018-05-23T12:25:18.867 回答