2016-11-16 4 views
0

사용자 정의 TableViewCell이 있습니다. 매초마다 타이머 레이블을 줄여야합니다. 나는 this 링크를 참조했습니다. 유일한 문제는 라벨의 텍스트를 변경할 수 없다는 것입니다. 콘솔에서 인쇄하면 값이 잘 전달됩니다. 셀의 값을 사용자 정의 셀 클래스에서 변경 한 후 TableView을 다시로드하려면 어떻게해야합니까? 맞춤 TableView 세포가 처음이므로 도움을 받으십시오. this 링크도 참조했습니다.Swift 3에서 NSTimer를 통해 사용자 정의 tableviewcell 레이블을 1 초마다 업데이트

class CustomCell: UITableViewCell { 

@IBOutlet weak var timerLabel: UILabel! 

var timer = Timer() 

func updateRow(){ 
    print("started timer") 
    timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(CustomCell.decreaseTimer), userInfo: nil, repeats: true) 
} 

func decreaseTimer(){ 
    let cell = self 
    let timerVal = cell.timerLabel.text 
    print("decrease "+timerVal!) 
    //how to reflect this timerVal value in the cell? 
}} 
+0

tableView 셀 및 타이머와 관련된 몇 가지 코드를 게시하여 아이디어를 얻을 수 있고이를 바탕으로 도움을 줄 수 있습니까? – CodeChanger

+0

CustomCell 코드를 추가했습니다. – Mamta

답변

0

레이블에 업데이트 시간 값을 지정해야합니다.

func decreaseTimer(){ 
    let cell = self 
    let timerVal = cell.timerLabel.text 
    print("decrease "+timerVal!) 
    //how to reflect this timerVal value in the cell? 
    cell.timerLabel.text = timerVal 
}}