2013-09-26 40 views
0

我有一个从数据库中获取的图像列表到iMagesArray。Objective-C在一个UI滚动视图中重复自动滚动图像,就像一个水平幻灯片

我的要求是要将图像作为横向显示在固定尺寸窗口中的幻灯片

同样喜欢http://www.nda4u.com/ * 谢谢这些2013 NDA会议主办单位: *线

+0

你想要的图像,其将自动滚动或滚动用户交互? – SayeedHussain

+0

自动滚动图像 – user2732294

+0

旋转循环一旦到达最后?你有图像作为网址或者你有实际的图像数据? – SayeedHussain

回答

-1

尝试

//... 
int i; 
} 
-(void) viewDidLoad{ 
//... whatever wour code in the view is... 
    [NSTimer scheduledTimerWithTimeInterval:2.0f target:self selector:@selector(animation:) userInfo:Nil repeats:Yes]; 
} 

-(void)animation{ 
    i++; 
    //i'd name the images just with numbers 
    int newView = mod(i,numberOfImagesInSlideShow); 
    NSString *name = [NSString stringWithFormat:@"%d",mod(i,numberOfTotalImages);] 
    UIImageView newImageView = [[UIImageView alloc] initWithImage[UIImage imageNamed:name]]; 
    self.imageView.center = CGPointMake(-self.bounds.size.width/numberOfImagesInSlideShow,self.bounds.size.height/2); 

    [self addSubView:newImageView]; 
    [UIView animateWithDuration:2.0f animations:^{ 
     for(int n=0;n<numberOfImagesInSlideShow;n++){ 
      if([self viewWithTag:(mod(i+n,numberOfImagesInSlideShow))]) 
       [self viewWithTag:(mod(i+n,numberOfImagesInSlideShow))].center = CGPointMake(n*self.bounds.size.width/numberOfImagesInSlideShow,self.bounds.size.height/2); 
     } 
    }        completion:^(BOOL finished){ 
     if([self viewWithTag:(mod(mod(i+numberOfImagesInSlideShow-1,numberOfImagesInSlideShow)))]) 
       [[self viewWithTag:(mod(i+numberOfImagesInSlideShow-1,numberOfImagesInSlideShow))] removeFromSuperView]; 
    }]; 
相关问题