Skip to main content
added 474 characters in body
Source Link
Prince Kumar Sharma
  • 12.6k
  • 4
  • 62
  • 90
-(void)doyouworkmoveCell:(UIButton*)sender
{
    if (sender.tag==0) {
        //move left
        if (count>0) {
            count--;
            NSLog(@"count == %i",count);
            [self snapToCellAtIndex:count withAnimation:YES];//paas index here to move to.
        }
    }else{
        //move right
        if (count<noOfCells-1) {
            count++;
            NSLog(@"count == %i",count);
            [self snapToCellAtIndex:count withAnimation:NO];YES];//paas index here to move to.
        }
    }
}

- (void) snapToCellAtIndex:(NSInteger)index withAnimation:(BOOL) animated
{
    NSIndexPath *IndexPath = [NSIndexPath indexPathForRow:index inSection:0];
    UICollectionViewCell *cell= [collectionView[_myCollectionView cellForItemAtIndexPath:IndexPath];
    [self.collectionView[_myCollectionView scrollToItemAtIndexPath:IndexPath atScrollPosition:UICollectionViewScrollPositionLeft animated:animated];
    UITextView *txtView=(UITextView*)[cell viewWithTag:21];
    [txtView becomeFirstResponder]; //in current cell with index 
}

use your custom cell type at this line

UICollectionViewCell *cell= [collectionView cellForItemAtIndexPath:IndexPath];

Hope this will help

-(void)doyouwork
{
    [self snapToCellAtIndex:1 withAnimation:NO];//paas index here to move to.
}

- (void) snapToCellAtIndex:(NSInteger)index withAnimation:(BOOL) animated
{
    NSIndexPath *IndexPath = [NSIndexPath indexPathForRow:index inSection:0];
    UICollectionViewCell *cell= [collectionView cellForItemAtIndexPath:IndexPath];
    [self.collectionView scrollToItemAtIndexPath:IndexPath atScrollPosition:UICollectionViewScrollPositionLeft animated:animated];
    UITextView *txtView=(UITextView*)[cell viewWithTag:21];
    [txtView becomeFirstResponder]; //in current cell with index 
}

use your custom cell type at this line

UICollectionViewCell *cell= [collectionView cellForItemAtIndexPath:IndexPath];

Hope this will help

-(void)moveCell:(UIButton*)sender
{
    if (sender.tag==0) {
        //move left
        if (count>0) {
            count--;
            NSLog(@"count == %i",count);
            [self snapToCellAtIndex:count withAnimation:YES];//paas index here to move to.
        }
    }else{
        //move right
        if (count<noOfCells-1) {
            count++;
            NSLog(@"count == %i",count);
            [self snapToCellAtIndex:count withAnimation:YES];//paas index here to move to.
        }
    }
}

- (void) snapToCellAtIndex:(NSInteger)index withAnimation:(BOOL) animated
{
    NSIndexPath *IndexPath = [NSIndexPath indexPathForRow:index inSection:0];
    UICollectionViewCell *cell= [_myCollectionView cellForItemAtIndexPath:IndexPath];
    [_myCollectionView scrollToItemAtIndexPath:IndexPath atScrollPosition:UICollectionViewScrollPositionLeft animated:animated];
    UITextView *txtView=(UITextView*)[cell viewWithTag:21];
    [txtView becomeFirstResponder]; //in current cell with index
}

use your custom cell type at this line

UICollectionViewCell *cell= [collectionView cellForItemAtIndexPath:IndexPath];

Hope this will help

added 162 characters in body
Source Link
Prince Kumar Sharma
  • 12.6k
  • 4
  • 62
  • 90
-(void)doyouwork
{
    [self snapToCellAtIndex:1 withAnimation:NO];//paas index here to move to.
}

- (void) snapToCellAtIndex:(NSInteger)index withAnimation:(BOOL) animated
{
    NSIndexPath *IndexPath = [NSIndexPath indexPathForRow:index inSection:0];
    UICollectionViewCell *cell= [collectionView cellForItemAtIndexPath:IndexPath];
    [self.collectionView scrollToItemAtIndexPath:IndexPath atScrollPosition:UICollectionViewScrollPositionLeft animated:animated];
    UITextView *txtView=(UITextView*)[cell viewWithTag:21];
    [txtView becomeFirstResponder]; //in current cell with index 
}

use your custom cell type at this line

UICollectionViewCell *cell= [collectionView cellForItemAtIndexPath:IndexPath];

Hope this will help

-(void)doyouwork
{
    [self snapToCellAtIndex:1 withAnimation:NO];//paas index here to move to.
}

- (void) snapToCellAtIndex:(NSInteger)index withAnimation:(BOOL) animated
{
    NSIndexPath *IndexPath = [NSIndexPath indexPathForRow:index inSection:0];
    UICollectionViewCell *cell= [collectionView cellForItemAtIndexPath:IndexPath];
    [self.collectionView scrollToItemAtIndexPath:IndexPath atScrollPosition:UICollectionViewScrollPositionLeft animated:animated];
    UITextView *txtView=(UITextView*)[cell viewWithTag:21];
    [txtView becomeFirstResponder]; //in current cell with index 
}

Hope this will help

-(void)doyouwork
{
    [self snapToCellAtIndex:1 withAnimation:NO];//paas index here to move to.
}

- (void) snapToCellAtIndex:(NSInteger)index withAnimation:(BOOL) animated
{
    NSIndexPath *IndexPath = [NSIndexPath indexPathForRow:index inSection:0];
    UICollectionViewCell *cell= [collectionView cellForItemAtIndexPath:IndexPath];
    [self.collectionView scrollToItemAtIndexPath:IndexPath atScrollPosition:UICollectionViewScrollPositionLeft animated:animated];
    UITextView *txtView=(UITextView*)[cell viewWithTag:21];
    [txtView becomeFirstResponder]; //in current cell with index 
}

use your custom cell type at this line

UICollectionViewCell *cell= [collectionView cellForItemAtIndexPath:IndexPath];

Hope this will help

added 162 characters in body
Source Link
Prince Kumar Sharma
  • 12.6k
  • 4
  • 62
  • 90
-(void)doyouwork
{
    [self snapToCellAtIndex:1 withAnimation:NO];//paas index here to move to.
}

- (void) snapToCellAtIndex:(NSInteger)index withAnimation:(BOOL) animated
{
    [textView becomeFirstResponder]; //inNSIndexPath current*IndexPath cell= with[NSIndexPath indexPathForRow:index inSection:0];
    NSIndexPath *path =UICollectionViewCell [NSIndexPath*cell= indexPathForRow:index[collectionView inSectioncellForItemAtIndexPath:0];IndexPath];
    [self.collectionView scrollToItemAtIndexPath:pathIndexPath atScrollPosition:UICollectionViewScrollPositionLeft animated:animated];
    UITextView *txtView=(UITextView*)[cell viewWithTag:21];
    [txtView becomeFirstResponder]; //in current cell with index 
}

Hope this will help

-(void)doyouwork
{
    [self snapToCellAtIndex:1 withAnimation:NO];//paas index here to move to.
}

- (void) snapToCellAtIndex:(NSInteger)index withAnimation:(BOOL) animated
{
    [textView becomeFirstResponder]; //in current cell with index 
    NSIndexPath *path = [NSIndexPath indexPathForRow:index inSection:0];
    [self.collectionView scrollToItemAtIndexPath:path atScrollPosition:UICollectionViewScrollPositionLeft animated:animated];
}

Hope this will help

-(void)doyouwork
{
    [self snapToCellAtIndex:1 withAnimation:NO];//paas index here to move to.
}

- (void) snapToCellAtIndex:(NSInteger)index withAnimation:(BOOL) animated
{
    NSIndexPath *IndexPath = [NSIndexPath indexPathForRow:index inSection:0];
    UICollectionViewCell *cell= [collectionView cellForItemAtIndexPath:IndexPath];
    [self.collectionView scrollToItemAtIndexPath:IndexPath atScrollPosition:UICollectionViewScrollPositionLeft animated:animated];
    UITextView *txtView=(UITextView*)[cell viewWithTag:21];
    [txtView becomeFirstResponder]; //in current cell with index 
}

Hope this will help

Source Link
Prince Kumar Sharma
  • 12.6k
  • 4
  • 62
  • 90
Loading