내가 performSelector:withObject:afterDelay
여기에 당신을 도울 것입니다 생각합니다.
진행률 표시 줄을 증가시킬 방법을 작성하십시오. 그 방법의 끝에서 동일한 방법으로 performSelector:withObject:afterDelay
에 1 초의 지연 시간이 걸릴 때까지 전화하십시오.
아마도이 메서드에 개체를 전달할 필요가 없으므로 nil을 사용할 수 있습니다.
편집 귀하의 경우에는
나는 이런 식으로 뭔가 추천 할 것입니다 :
- (IBAction)startProgressBar:(id)sender
{
// Initialize the progress bar to go from 0 to 100
[progress setMinValue:0.0];
[progress setMaxValue:100.0];
[progress setDoubleValue:0.0];
// Start the auto-increment calls
[self incrementProgressBar];
}
- (void)incrementProgressBar
{
// Increment the progress bar value by 1
[progress incrementBy:1.0];
// If the progress bar hasn't reached 100 yet, then wait a second and call again
if([progress doubleValue] < 100.0)
[self performSelector:@selector(incrementProgressBar) withObject:nil afterDelay:1];
}
가 이미 코드 줄을 알고를하지만 난 그게 나에게 자세한 내용을 적어주세요 방법 LOOP 모른다 :) – CocoaCoder
끝에 코드 줄이있는 메서드를 작성한다고 가정 해보십시오. 메서드가 실행 된 후에는 지연 후 다시 실행됩니다. 그리고 다시. 재귀 적 방법과 비슷합니다. – Aaron
네,하지만 바가 100 %가 될 때까지 루프를 만들고 싶습니다. 루프를 멈추고 싶습니다. D – CocoaCoder