title: UICollectionView - Horizontal AutoScroll with Timer
body: <p>I am using Horizontal Auto Scroll using timer. I want it to scroll one by one.  </p>
  
  <p>In my case it is scrolling continuos from left to right. and in last it also scroll white space after last cell.</p>
  
  <pre><code>@interface AccountsVC ()&lt;UICollectionViewDataSource,   UICollectionViewDelegate,UICollectionViewDelegateFlowLayout&gt;
  {
   CGFloat width_Cell;
   NSTimer *autoScrollTimer;
  }
  
  - (void)viewDidLoad
  {
   [super viewDidLoad];
   width_Cell = 0.0;
  }
  
  - (void)viewDidAppear:(BOOL)animated
  {
   [super viewDidAppear:animated];
   [self configAutoscrollTimer];
   }
  
  - (void)viewDidDisappear:(BOOL)animated
  {
   [super viewDidDisappear:animated];
   [self deconfigAutoscrollTimer];
  }
  
  - (void)configAutoscrollTimer
  {
   autoScrollTimer = [NSTimer scheduledTimerWithTimeInterval:0.03 target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
   }
  
  - (void)deconfigAutoscrollTimer
  {
   [autoScrollTimer invalidate];
   autoScrollTimer = nil;
  }
  
  - (void)onTimer
  {
   [self autoScrollView];
  }
  
  - (void)autoScrollView
   {
   CGPoint initailPoint = CGPointMake(width_Cell, 0);
   if (CGPointEqualToPoint(initailPoint, self.collectionView.contentOffset))
   {
      if (width_Cell &lt; self.collectionView.contentSize.width)
      {
          width_Cell += 0.5;
      }else
      {
          width_Cell = -self.view.frame.size.width;
      }
      CGPoint offsetPoint = CGPointMake(width_Cell, 0);
      self.collectionView.contentOffset = offsetPoint;
  }else
   {
      width_Cell = self.collectionView.contentOffset.x;
   }
  }
  </code></pre>