我想創建一個頁面,它應該在頂部有一個映射,在底部應該有一個5行的tableview。所以我創建了UIViewController把我的地圖視圖,然後把TableView。我創建myViewController.swift和myTableViewCell.swiftUIView中的Swift TableView不顯示數據
但是,當我嘗試在模擬器上沒有數據顯示在tableview上。只有空細胞。我收到了沒有錯誤
這是我的代碼。謝謝
import UIKit
import MapKit
class myViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var mapView: MKMapView!
var labels = ["some arrays"]
var images = ["some image names in an array"]
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return labels.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("mySegue", forIndexPath: indexPath) as! myTableViewCell
cell.myCellLabel.text = labels[indexPath.row]
cell.myCellImage.image = UIImage(named: images[indexPath.row])
return cell
}
}
我真的已經很努力解決這個問題,但解決的辦法是那麼容易嗎?:)非常感謝你 – fuzunspm
不要忘記辦始終做到這一點,也與的CollectionView,... – Masterfego
這是什麼兩行真的嗎?在此先感謝 –