UILabel
을 "while 루프"내에서 업데이트하려고하지만 UILabel
텍스트가 변경되지 않았습니다. 나는 그것이 iOS
에 대한 평소와 같이 주 스레드에서 현재 실행 루프 사이클의 끝에 표시된다는 것을 알고 있습니다. 그러나이 문제를 어떻게 해결할 수 있습니까? ftp.AsyncFinished 함수는 외부 chilkat ftp 모듈에서 제공됩니다.UILabel을 "while 루프"로 업데이트하십시오.
데이터는 매 초마다 업데이트됩니다. 이 포럼과 Apple 설명서를 검색했지만 메인 스레드의 "while 루프"내에 UILabel
을 업데이트하는 올바른 방법을 알 수 없었습니다. while 루프 대신에 무엇을 사용하면 주 스레드가 UILabel
을 업데이트 할 수 있습니다.
while (ftp.AsyncFinished != YES) {
// here is the code getting data from the cilkat FTP module stored in PercentOfFile and MinutesRemaining
NSString *content =[[NSString alloc] initWithFormat:@"%.0f%% done%.0fmin left",PercentOfFile,MinutesRemaining ];
[LabelProgress setText:content];
}
http://stackoverflow.com/questions/6363828/updating-uilabel-in-the-middle-of-a-for-loop – Habib
@ Habbib.OSU'runMode : beforeDate :'접근법은 매우 위험합니다. GCD에 기반한이 질문에 대한 더 나은 솔루션을 추가했습니다. –