0

こんにちは、電話プログラミングは初めてです。UIImage以下のコードを使用して、次のコードを使用して自動的に1つずつ表示しています。ここでは、すべての表示が停止したらUIImages保存していますが、ここでは、すべてが終了したらそれを停止するにはどうすればよいですか。NSArrayUIImagesUIImages

- (void)displayPicture{
    for (NSString* path in array000) { 
        [blaukypath2 addObject:[UIImage imageWithContentsOfFile:path]]; 
        NSLog(@"%@",path); 
    } 

    NSLog(@"%@",blaukypath2); 
    NSLog(@"%icurrentImage DIDF",currentImage); 

    currentImage++; 
    if (currentImage >= blaukypath2.count) currentImage = 0; 

    UIImage *blaukyyimag = [blaukypath2 objectAtIndex:currentImage]; 
    [img10 setImage:blaukyyimag]; 
    NSLog(@"%icurrentImage++ DIDF",currentImage);
}
4

4 に答える 4

0

UIImage を使用している場合、これを実行できる最も簡単なことは次のとおりです。

myUIImage = nil;

ただし、 myUIImage がstoryboardまたはxibファイルに接続されていることを確認してください。

于 2013-10-24T14:35:06.120 に答える
0

コードがどのように機能しているか正確にはわかりませんが、何らかのfororwhileループにある場合は、次の行が問題である可能性があります。

currentImage++; 
if (currentImage >= blaukypath2.count) currentImage = 0;

をインクリメントcurrentImageしていますが、 の最後の画像に到達すると、0 にblaukypath2設定され、最初からやり直されます。currentImage代わりにこれを試してください:

if (currentImage < blaukypath2.count)
{
    currentImage++; 
}
于 2013-10-24T14:47:43.417 に答える
0

あなたのコードには 2 つの問題があります。

1 - 画像の初期化ループを「再生メソッドを終了しました」から移動する必要があります。いくつかの初期化メソッドで一度それを行う必要があります。同じ場所で currentImage をゼロに初期化する必要があります。

2 - 各画像を 1 回だけ表示するには、「メソッドを終了しました」で次のコードが必要です

if (currentImage < blaukypath2.count) {
    UIImage *blaukyyimag = [blaukypath2 objectAtIndex:currentImage]; 
    [img10 setImage:blaukyyimag]; 
    NSLog(@"%icurrentImage++ DIDF",currentImage);
    currentImage++;
} else {
    [img10 setImage:nil]; 
    NSLog(@"all images was displayed DIDF");
}
于 2013-10-25T15:19:31.587 に答える