我正在工作一个应用程序。在这个随机数的时间图像是滚动的..然后停止图像..在我的代码中,第一个随机数是生成的,它存储在 n..例如。随机否生成 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;
}
}
我想在随机不匹配时停止滚动意味着n == i
我该怎么做?