Simultaneous display of multiple images inside a loop

I am trying to get a stream display in a loop. I understand that, in principle, I could hang up the program by putting an endless loop connected, for example, with the click of a button. In any case, when I run this code, the counter works very well, and the frames from the camera are captured (I can save them as a series of files.) However, displaying using setImage does nothing until the end of the loop when it displays the last image on the screen. My question is: If the program starts sequentially, as described in the documentation, why does the display not occur, and the code on the other side of the display command works fine? Is the display just “reset” to a parallel process, in which case I should just put a delay loop waiting for the display to complete?

Thanks WMW

uint32 MaxRuns = 10;
for (uint32 NoRuns = 0 ; NoRuns < MaxRuns ; NoRuns++)   
{
//
//Here is some code to capture each image from the camera
//and save them to image.tif
//
inFilePath = @"/Volumes/Portable_Mac/Programming/CameraData/image.tif";
    [TestImage initWithContentsOfFile:inFilePath];      
[viewWindow setImage: TestImage];
    printf("run number:%d\n",NoRuns);
}
+1
1

, . setImage:, image ivar , , , setNeedsDisplay:. . , , , ( , ) , , for.

(performSelector:withObject:afterDelay: ). , :

[NSTimer scheduledTimerWithTimeInterval:2.5
                                 target:self
                               selector:@selector(changeDisplayedImage:)
                               userInfo:nil
                                repeats:YES];

:

- (void)changeDisplayedImage:(NSTimer *)tim {
    // currImageIdx is an ivar keeping track of our position
    if( currImageIdx >= [imageArray count] ){
        [tim invalidate];
        return;
    }
    [viewWindow setImage:[imageArray objectAtIndex:currImageIdx]];
    currImageIdx++;
}

, , , , , , . , , display ( setNeedsDisplay:).

+2

All Articles