NSTimer/NSOperationQueue の実行に一貫性がないという UI の問題を解決しようとしています。NSTimer または NSInvocationOperation を使用して以下のコードをトリガーするかどうかに関係なく、多くの場合、必要に応じてパフォーマンスが向上しますが、動作が遅くなることが何度かあります (また、以下の例のように、コードが 1 秒以上実行される場合もあります) )。
NSInvocationOperation を介して呼び出される私のコードは次のとおりです。
-(void) progressAsynch{
for (count = 1; count<=100; count++) {
// Reposition Label's CGRect.
[self performSelectorOnMainThread:@selector(moveLabelToNewPosition) withObject:nil waitUntilDone:YES];
//Update the progress of the progress view
[self performSelectorOnMainThread:@selector(advanceProgressViewProgress) withObject:nil waitUntilDone:YES];
//Sleep for 10 millisecs
[NSThread sleepForTimeInterval:0.01];
//if the progress view has progressed fully call main thread to to next tasks.
if(progressView.progress == 1) {
[self performSelectorOnMainThread:@selector(processResult) withObject:nil waitUntilDone:YES];
}
}
}
NSTimer (10 ミリ秒ごとにトリガー) によって呼び出されるメソッドのコードは、上記と非常に似ていますが、for ループが含まれていないという点だけです。
明らかに、この処理の外部に、このパフォーマンスを頻繁に低下させている何かがあるようです。
同様の問題を抱えているかどうか、または私を助ける可能性のあるポインター/ヒントがあるかどうかを知りたい.
前もって感謝します..