【发布时间】:2019-09-24 07:31:52
【问题描述】:
import UIKit
class ViewController: UIViewController,UITableViewDelegate, UITableViewDataSource{
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var addImage: UIImage!
let animalNames = ["lion","monky","tiger"]
let animalImages = [UIImage(named: "lion"), UIImage(named: "monky"), UIImage(named: "tiger")]
override func viewDidLoad() {
super.viewDidLoad()
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return animalImages.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "mycell",for:indexPath) as! ImageWithTableViewCell
cell.image1.image=self.animalImages[indexPath .row]
cell.label1.text=self.animalNames[indexPath .row]
return cell
}
@IBAction func addingImages(_ sender: UIButton) {
//what code I have to write here
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
【问题讨论】:
标签: swift4