在UIControllerView Swift 4

时间:2018-02-23 19:09:04

标签: swift xcode uitableview firebase

我正在学习如何在Swift 4中编码,但我遇到了一个问题,我的表视图没有显示在View控制器上!我试图在每个单元格中加载进度视图(进度的计数并不重要,我只是希望它在我变得更复杂之前工作)。 UiViewController还有一个标签栏控制器。

我稍后会将进度视图的倒计时速度设置为存储在firebase中的值。

我不明白为什么这是空白的!似乎没有错误??

FirstViewController

导入UIKit 进口基金会 导入Firebase 导入FirebaseAuth

类FirstViewController:UIViewController,UITableViewDataSource,UITableViewDelegate {

var arrayOfProcesses :[processCell] = []


@IBOutlet weak var tabelView: UITableView!
@IBOutlet weak var lblDisplayName: UILabel!




@IBAction func btnLogOut(_ sender: Any) {


    try! Auth.auth().signOut()
    self.dismiss(animated: false, completion: nil)
}

func CreateArray() -> [processCell]{

    var tempProcesses :[processCell] = []

    let process1 = processCell(process:"Position passenger Bridge/Open Door",progress: 10,timeleft: "10")
     let process2 = processCell(process:"Deplane Passengers",progress: 10,timeleft: "10")
     let process3 = processCell(process:"Service Cabin",progress: 10,timeleft: "10")
     let process4 = processCell(process:"Unload Baggage compartment",progress: 10,timeleft: "10")
     let process5 = processCell(process:"Position passenger Bridge/Open Door",progress: 10,timeleft: "10")

    tempProcesses.append(process1)
    tempProcesses.append(process2)
    tempProcesses.append(process3)
    tempProcesses.append(process4)
    tempProcesses.append(process5)

    return tempProcesses

}



override func viewDidLoad() {
    super.viewDidLoad()

    arrayOfProcesses = CreateArray()


    tabelView.delegate = self
     tabelView.dataSource = self



//    Timer.scheduledTimer(timeInterval: 0.30, target: self, selector: #selector(SetProgressbar), userInfo: nil, repeats: /true)

    self.tabelView.reloadData()
}





func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return arrayOfProcesses.count
}


func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let process = arrayOfProcesses[indexPath.row]

    let cell = tableView.dequeueReusableCell(withIdentifier: "processCell") as! ProcessTableViewCell

    cell.setProcess(process: process)

    return cell
}

}

ProcessTableViewCell.swift

导入UIKit

类ProcessTableViewCell:UITableViewCell {

@IBOutlet weak var progressViewBar: UIProgressView!
@IBOutlet weak var lblProcess: UILabel!
@IBOutlet weak var lblTimer: UILabel!

var progressValue: Float = 0


func setProcess(process : processCell) {

    lblProcess.text = process.process
    lblTimer.text = process.timeleft


   Timer.scheduledTimer(timeInterval: 0.30, target: self, selector: #selector(setProgressbar), userInfo: nil, repeats: true)
}

@objc func setProgressbar(){

    progressValue += 0.30
    progressViewBar.progress = progressValue

}

}

ProcessCell

导入基金会 导入UIKit

class processCell {

var process:String     var progress:Int     var timeleft:String

init(process : String,progress : Int,timeleft : String){

    self.process = process
    self.progress = progress
    self.timeleft = timeleft
}

}

非常感谢任何帮助:)谢谢

0 个答案:

没有答案