在Xcode 7中我正在开发自定义tableView,因此它们是一个问题,每个2个单元格在一个之后未打印。我不知道这个问题是怎么来的?
这是我的自定义单元格类:
导入UIKit
class CustomCellTwo:UITableViewCell {
@IBOutlet weak var indx: UILabel!
@IBOutlet weak var dateOne: UILabel!
@IBOutlet weak var duaration: UILabel!
@IBOutlet weak var distance: UILabel!
@IBOutlet weak var ignitionOff: UILabel!
@IBOutlet weak var locationOne: UILabel!
@IBOutlet weak var dateTwo: UILabel!
@IBOutlet weak var ignitionOn: UILabel!
@IBOutlet weak var locationTwo: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
}
这是我的ViewControllerClass: 进口基金会 导入UIKit
类TripReport:UIViewController,UITableViewDelegate,UITableViewDataSource {
var dateTimeOn = [ "2016-Jan-20 11:36 AM","2016-Jan-20 11:25 AM","2016-Jan-20 11:15 AM","2016-Jan-20 11:05 AM","2016-Jan-20 11:04 AM","2016-Jan-20 11:02 AM","2016-Jan-20 11:00 AM","2016-Jan-20 10:57 AM","2016-Jan-20 10:57 AM","2016-Jan-20 10:53 AM"]
var dateTimeOff = [ "2016-Jan-20 11:36 AM","2016-Jan-20 11:25 AM","2016-Jan-20 11:15 AM","2016-Jan-20 11:05 AM","2016-Jan-20 11:04 AM","2016-Jan-20 11:02 AM","2016-Jan-20 11:00 AM","2016-Jan-20 10:57 AM","2016-Jan-20 10:57 AM","2016-Jan-20 10:53 AM"]
var eventOn = [ "IGNITION","IGNITION ON","IGNITION ON","IGNITION ON","IGNITION ON","IGNITION ON","IGNITION ON","IGNITION ON","IGNITION ON","IGNITION ON"]
var eventOff = [ "IGNITION OFF","IGNITION OFF","IGNITION OFF","IGNITION OFF","IGNITION OFF","IGNITION OFF","IGNITION OFF","IGNITION OFF","IGNITION OFF","IGNITION OFF"]
var duaration = [ "00 hr 00 min","00 hr 00 min","00 hr 00 min","00 hr 00 min","00 hr 00 min","00 hr 00 min","00 hr 00 min","00 hr 00 min","00 hr 00 min","00 hr 00 min"]
var distance = [ "00 km","00 km","00 km","00 km","00 km","00 km","00 km","00 km","00 km","00 km"]
var locationOn = [ "7.88 KM SE of Police Line Constibilary, Faisalabad - Jaranwala Road, FAISALABAD, PUNJAB, PK","0.47 KM SE of Police Line Constibilary, Faisalabad - Jaranwala Road, FAISALABAD, PUNJAB, PK","0.99 KM SE of Police Line Constibilary, Faisalabad - Jaranwala Road, FAISALABAD, PUNJAB, PK","0.99 KM SE of Police Line Constibilary, Faisalabad - Jaranwala Road, FAISALABAD, PUNJAB, PK","0.99 KM SE of Police Line Constibilary, Faisalabad - Jaranwala Road, FAISALABAD, PUNJAB, PK","1.01 KM SE of Police Line Constibilary, Faisalabad - Jaranwala Road, FAISALABAD, PUNJAB, PK","1.16 KM SE of Police Line Constibilary, Faisalabad - Jaranwala Road, FAISALABAD, PUNJAB, PK","1.03 KM SE of Police Line Constibilary, Faisalabad - Jaranwala Road, FAISALABAD, PUNJAB, PK","0.98 KM SE of Police Line Constibilary, Faisalabad - Jaranwala Road, FAISALABAD, PUNJAB, PK","1.62 KM SE of Police Line Constibilary, Faisalabad - Jaranwala Road, FAISALABAD, PUNJAB, PK"]
var locationOff = [ "7.88 KM SE of Police Line Constibilary, Faisalabad - Jaranwala Road, FAISALABAD, PUNJAB, PK","0.47 KM SE of Police Line Constibilary, Faisalabad - Jaranwala Road, FAISALABAD, PUNJAB, PK","0.99 KM SE of Police Line Constibilary, Faisalabad - Jaranwala Road, FAISALABAD, PUNJAB, PK","0.99 KM SE of Police Line Constibilary, Faisalabad - Jaranwala Road, FAISALABAD, PUNJAB, PK","0.99 KM SE of Police Line Constibilary, Faisalabad - Jaranwala Road, FAISALABAD, PUNJAB, PK","1.01 KM SE of Police Line Constibilary, Faisalabad - Jaranwala Road, FAISALABAD, PUNJAB, PK","1.16 KM SE of Police Line Constibilary, Faisalabad - Jaranwala Road, FAISALABAD, PUNJAB, PK","1.03 KM SE of Police Line Constibilary, Faisalabad - Jaranwala Road, FAISALABAD, PUNJAB, PK","0.98 KM SE of Police Line Constibilary, Faisalabad - Jaranwala Road, FAISALABAD, PUNJAB, PK","1.62 KM SE of Police Line Constibilary, Faisalabad - Jaranwala Road, FAISALABAD, PUNJAB, PK"]
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
print("Trip Report Called")
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10;
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = self.tableView.dequeueReusableCellWithIdentifier("celltwo", forIndexPath: indexPath) as! CustomCellTwo
print("table view cell")
cell.dateOne.text = self.dateTimeOff[indexPath.row]
cell.duaration.text = self.duaration[indexPath.row]
cell.distance.text = self.distance[indexPath.row]
cell.ignitionOn.text = self.eventOn[indexPath.row]
cell.ignitionOff.text = self.eventOff[indexPath.row]
cell.locationOne.text = self.locationOff[indexPath.row]
cell.locationTwo.text = self.locationOn[indexPath.row]
cell.dateOne.text = self.dateTimeOff[indexPath.row]
cell.dateTwo.text = self.dateTimeOn[indexPath.row]
cell.indx.text = "\(indexPath.row)";
return cell
}
}
注意:我对其他tableview使用相同的技术,这是完美的。 现在我的两个视图都加入了Tab Bar Controller ..