Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在iphone的UIScrollView中滚动图像_Iphone_Image_Scroll - Fatal编程技术网

在iphone的UIScrollView中滚动图像

在iphone的UIScrollView中滚动图像,iphone,image,scroll,Iphone,Image,Scroll,我正在使用一个应用程序。在这个随机数的时间里,图像是滚动的。然后停止图像。在我的代码中,第一个随机数是生成的,它存储在n中。例如,随机数是生成12,然后图像是滚动的12倍,然后停止 - (void)viewDidLoad { int n = 1 + arc4random() % 10 + 10; NSString *string = [NSString stringWithFormat:@"%i",n]; //lbl.text = string; NSUIntege

我正在使用一个应用程序。在这个随机数的时间里,图像是滚动的。然后停止图像。在我的代码中,第一个随机数是生成的,它存储在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;       

    }

}
-(void)viewDidLoad
{
int n=1+arc4random()%10+10;
NSString*string=[NSString stringWithFormat:@“%i”,n];
//lbl.text=字符串;
NSUI;
对于(i=1;i试试这个

- (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++)
    {
        if(n == i)
          break;
        else {

       // [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];

          }    

    }

}
-(void)viewDidLoad
{
int n=1+arc4random()%10+10;
NSString*string=[NSString stringWithFormat:@“%i”,n];
//lbl.text=字符串;
NSUI;

对于(i=1;i[firstScrollView setContentOffset:CGRectMake(n*firstScrollView.frame.size.width,firstScrollView.frame.size.height)]

您只需设置scrollView的内容偏移量