GMGridView icon indicating copy to clipboard operation
GMGridView copied to clipboard

scrollToObjectAtIndex:atScrollPosition:animated: doesn't seem to work

Open jrmgx opened this issue 13 years ago • 4 comments

This method (void)scrollToObjectAtIndex:(NSInteger)index atScrollPosition:(GMGridViewScrollPosition)scrollPosition animated:(BOOL)animated is not working at all with my project

This is how I init the GMGrid


    self.grid = [[GMGridView alloc] initWithFrame:CGRectMake(14, 228, 292, 260)];
    self.grid.dataSource = self;

    self.grid.itemSpacing = 0;
    self.grid.minEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
    self.grid.clipsToBounds = YES;
    [self.grid setPagingEnabled:YES];
    [self.grid setLayoutStrategy:[GMGridViewLayoutStrategyFactory strategyFromType:GMGridViewLayoutHorizontalPagedLTR]];

    [self.mainView addSubview:self.grid];

and after that in my code I add a value to the self.data, plus a call to [self.grid reloadData] (and the grid is updated) and then [self.grid scrollToObjectAtIndex:(self.data.count - 1) atScrollPosition:GMGridViewScrollPositionBottom animated:YES];

I tried with different value for atScrollPosition:GMGridViewScrollPositionBottom with no success, do you have any clue about what's going wrong?

Thanks in advance

jrmgx avatar May 16 '12 10:05 jrmgx

Hi, I have been observing the same issue while trying to set a specific index with the HorizontalPagedLTR strategy. I am not working on the latest version right now though. Was there a fix on this issue ? thanks!

ghost avatar May 28 '12 23:05 ghost

I am observing the same issue, is it working now?

narup avatar Sep 30 '12 22:09 narup

I don't know if this works for a GMGridViewLayoutHorizontalPagedLTR layout strategy, but I was having the same issue with a GMGridViewLayoutHorizontal layout strategy.

I got it to work by setting the layoutStrategy before the dataSource or the GMGridView.

jallen avatar Nov 27 '12 22:11 jallen

Isn't working...

I had to use this (I'm using a UIPageControl):

CGRect frame = _gmGridView.frame;
frame.origin.x = frame.size.width * page;
frame.origin.y = 0;
[_gmGridView scrollRectToVisible:frame animated:YES];

Lascorbe avatar Dec 27 '12 09:12 Lascorbe