ココアの開発はかなり新しく、おそらく根本的な問題に固執しています。
つまり、私のアプリの UI は、下部に nsslider がある単純なウィンドウのように見えます。必要なのは、N 個の画像を生成して、アプリ ウィンドウの N 個の nsviews に配置することです。
これまでの機能:
- スライダーをクリックして (押したまま)、ドラッグします。ドラッグしている間、ビューに何も起こりません (画像は生成されません)。スライダーを放すと、画像が生成され、ビューがいっぱいになります。
 
私が欲しいもの: - スライダーを動かしているときに、ビューを写真で埋める必要があります。
NSSlider プロパティの小さなチェック ボックスを見つけて継続的に使用していますが、スライダーを放すまでイメージ ジェネレーターは何もしません。
これが私のコードです:
// slider move action
- (IBAction)sliderMove:(id)sender
{   
    [self generateProcess:[_slider floatValue];
}
// generation process
- (void) generateProcess:(Float64) startPoint
{
    // create an array of times for frames to display
    NSMutableArray *stops = [[NSMutableArray alloc] init];
    for (int j = 0; j < _numOfFramesToDisplay; j++)
    {
        CMTime time = CMTimeMakeWithSeconds(startPoint, 60000);
        [stops addObject:[NSValue valueWithCMTime:time]];
        _currentPosition = initialTime;   // set the current position to the last frame displayed
        startPoint+=0.04; // the step between frames is 0.04sec
    }
    __block CMTime lastTime = CMTimeMake(-1, 1);
    __block int count = 0;
    [_imageGenerator generateCGImagesAsynchronouslyForTimes:stops
                                          completionHandler:^(CMTime requestedTime, CGImageRef image, CMTime actualTime,AVAssetImageGeneratorResult result, NSError *error)
     {
         if (result == AVAssetImageGeneratorSucceeded)
         {
             if (CMTimeCompare(actualTime, lastTime) != 0)
             {
                 NSLog(@"new frame found");
                 lastTime = actualTime;
             }
             else
             {
                 NSLog(@"skipping");
                 return;
             }
             // place the image onto the view
             NSRect rect = CGRectMake((count+0.5) * 110, 500, 100, 100);
             NSImageView *iView = [[NSImageView alloc] initWithFrame:rect];
             [iView setImageScaling:NSScaleToFit];
             NSImage *myImage = [[NSImage alloc] initWithCGImage:image size:(NSSize){50.0,50.0}];
             [iView setImage:myImage];
             [self.windowForSheet.contentView addSubview: iView];
             [_viewsToRemove addObject:iView];
         }
         if (result == AVAssetImageGeneratorFailed)
         {
             NSLog(@"Failed with error: %@", [error localizedDescription]);
         }
         if (result == AVAssetImageGeneratorCancelled)
         {
             NSLog(@"Canceled");
         }
         count++;
     }];
}
}
ご意見やアイデアがありましたら、私と共有してください。本当に感謝します!
ありがとうございました


