0
재생 단추를 클릭 할 때 tableview의 첫 번째 셀을 강조 표시해야합니다. 그런 다음 강조 표시된 셀이 해당 시간 간격으로 변경되는 시간 간격 배열을 유지해야합니다. 도움이 pls.가변 시간 간격 후 테이블 뷰에서 강조 표시된 셀 변경
재생 단추를 클릭 할 때 tableview의 첫 번째 셀을 강조 표시해야합니다. 그런 다음 강조 표시된 셀이 해당 시간 간격으로 변경되는 시간 간격 배열을 유지해야합니다. 도움이 pls.가변 시간 간격 후 테이블 뷰에서 강조 표시된 셀 변경
당신은 다음과 같이 사용할 수 있습니다
var lastSelectedIndexPath: IndexPath?
func viewDidLoad() {
Timer.scheduledTimer(timeInterval: 2.0, target: self, selector: #selector(timerFunc), userInfo: nil, repeats: true)
}
@objc func timerFunc() {
if lastSelectedIndexPath != nil {
tableView(self.table, didUnhighlightRowAt: lastSelectedIndexPath!)
}
tableView(self.table, didHighlightRowAt: IndexPath(row: YOUR_ROW, section: YOUR_SECTION))
}
func tableView(_ tableView: UITableView, didHighlightRowAt indexPath: IndexPath) {
let cell = tableView.cellForRow(at: indexPath)
cell?.backgroundColor = UIColor.red
lastSelectedIndexPath = indexPath
}
func tableView(_ tableView: UITableView, didUnhighlightRowAt indexPath: IndexPath) {
let cell = tableView.cellForRow(at: indexPath)
cell?.backgroundColor = UIColor.clear
}
나는이 질문에 대한 나의 이해를 바탕으로이 질문에 대답하고 있습니다. 약간의 시간이 지난 후에 테이블 뷰 셀을 강조 표시한다고 가정합니다.
[NSTimer scheduledTimerWithTimeInterval:2.0
target:self
selector:@selector(targetMethod:)
userInfo:nil
repeats:YES];
- (void)targetMethod {
NSIndexPath *defaultIndexPath = [NSIndexPath indexPathForRow:Any_Row_Number inSection:Any_Section_Number];
[self tableView:[self tableView] didSelectRowAtIndexPath:defaultIndexPath];
}