ボタンを押すごとに、プロジェクト内に準備した画像を番号順に交代で表示させたいと考えています。
詳細は以下の通りです。
・画像ファイルをプロジェクト内に複数用意する。
ファイル名はphoto01.jpg ~ photo10.jpg。
・UIImageViewにまずはphoto01を表示させる。
・ボタンを押したらphoto02がphoto01の代わりに表示される。
このようにしたいと考えています。
書いてみたコードは以下の通りです。
-
(IBAction)btTugi:(NSTimer *)timer{
int sequence = 0;
NSString *imageName = [NSString stringWithFormat: @"photo%d", sequence++];
NSLog(@"%@", imageName);
NSString *imagePath = [[NSBundle mainBundle] pathForResource:imageName
ofType:@"jpg"];
UIImage *image = [[UIImage alloc] initWithContentsOfFile:imagePath];image = [[UIImage alloc] initWithContentsOfFile:imagePath];
if (sequence > 100 && [timer isValid]) {
[timer invalidate];
NSLog(@"stop");
}
self.detailImageView.image = image;
}
どなたか改善点をご教示頂けないでしょうか。
以上、何卒よろしくお願いいたします。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。