알림이 실행될 때 appdelegate 함수가 호출됩니다. 이 함수가 호출 될 때 특정 ViewController에 대한 액세스 권한을 얻고 현재 View인지 여부에 관계없이 테이블 셀을 조작하려고합니다. rootViewController 메소드를 사용하여이 작업을 수행 할 수 있었지만 더 이상 루트보기로 설정되지 않아 더 이상 작동하지 않습니다.AppDelegate의 특정보기와 어떻게 상호 작용할 수 있습니까?
나는 현재이 코드를 사용하고 있습니다 :
let stopOption = UIAlertAction(title: "OK", style: .default) {
(action:UIAlertAction)->Void in self.audioPlayer?.stop()
print("Stop index is \(index)")
Alarms.sharedInstance.setEnabled(false, AtIndex: index)
let sb = UIStoryboard(name: "Main", bundle: nil)
let mainVC = sb.instantiateViewController(withIdentifier: "MainVC")
dump(mainVC)
let cells = (mainVC as! MainAlarmViewController).tableView.visibleCells
dump(cells)
for cell in cells
{
if cell.tag == index{
print("Found the cell")
let sw = cell.accessoryView as! UISwitch
sw.setOn(false, animated: false)
}
}
}
첫 번째 "덤프"문이 올바른의 ViewController를 반환하지만이 파단 및 제 덤프 문 반환의 표시하지 않습니다 "- 0 요소".
모든 도움을 주실 수 있습니다. 이 기능은 내가 특정의 ViewController에 접근하고 당신이 여기 Notification
를 사용할 필요가있는 내용은 현재보기 여부를
인지 여부를 테이블 셀을 조작 바라고이라고
는
ViewController
에 잡을 수 있습니다. 기본보기가로드 된 후에 만 하위보기에 액세스 할 수 있습니다. –함수가 호출 될 때까지 어떤 컨트롤러가 표시됩니까? –
이 알림이 도착할 때 MainAlarmViewController가로드되고 MainAlarmViewController가 현재 표시되는지 여부에 관계없이 셀이 업데이트되지 않는다고 추가해야합니다. – user1528944