この乱数で画像がスクロールされます..そして画像を停止します..ここで私のコードでは、最初の乱数が生成され、nに保存されます.. ランダムなnoは12を生成し、次に12回画像がスクロールされ、その後停止します..
- (void)viewDidLoad
{
int n = 1 + arc4random() % 10 + 10;
NSString *string = [NSString stringWithFormat:@"%i",n];
//lbl.text = string;
NSUInteger i;
for (i = 1; i <= kNumImages; i++)
{
// [kNumImages addObject:[NSNumber numberWithInt:i]];
NSString *imageName = [NSString stringWithFormat:@"%d.png", i];
UIImage *image = [UIImage imageNamed:imageName];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
CGRect rect = imageView.frame;
rect.size.height = kScrollObjHeight;
rect.size.width = kScrollObjWidth;
imageView.frame = rect;
imageView.tag = i;
lbl.text = string;
[FirstScrollView addSubview:imageView];
[imageView release];
if(n == i){
break;
}
}
ランダムな no が一致する場合にスクロールを停止したいのですが、n == i
どうすればそれを行うことができますか?