Coder Social home page Coder Social logo

Comments (20)

steipete avatar steipete commented on June 9, 2024

How exactly are they misaligned? Can you provide screenshots?

from gmgridview.

 avatar commented on June 9, 2024

Start example, choose paging strategy layout, swipe to page other than 1st or last, rotate device and gridview will display space somewhere in a middle between two pages, and not automatically scroll to beginning of page.

from gmgridview.

gmoledina avatar gmoledina commented on June 9, 2024

Yup I'm able to reproduce it. Will be fixed soon.

from gmgridview.

kylefox avatar kylefox commented on June 9, 2024

I think I'm experiencing the same issue (see screenshot). Any updates on this issue? Thanks!

from gmgridview.

gmoledina avatar gmoledina commented on June 9, 2024

Next in my list !

Out of curiosity, what's this app? Already in the appStore?

from gmgridview.

kylefox avatar kylefox commented on June 9, 2024

Awesome, thanks! Let me know if there's anything I can do to help (although I'm quite a newb with iOS).

(The app isn't released yet, but I'll definitely tell you more about it once it is!)

from gmgridview.

tonyarnold avatar tonyarnold commented on June 9, 2024

@gmoledina how'd you go with this error? I'm seeing it while using the development branch on an iPhone app.

from gmgridview.

LauterAlsDerRest avatar LauterAlsDerRest commented on June 9, 2024

I fixed the issue for myself by implementing

  • (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    CGFloat pageWidth = _scrollView.frame.size.width;
    currentPage = floor((_scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
    }

in GMGridview

and doing
CGRect frame = _scrollView.frame;
frame.origin.x = frame.size.width * currentPage;
frame.origin.y = 0;
[_scrollView scrollRectToVisible:frame animated:NO];

at the end of - (void)relayoutItemsAnimated:(BOOL)animated in GMGridview

more of a bandaid-fix but it works.

from gmgridview.

tonyarnold avatar tonyarnold commented on June 9, 2024

I'll give you an easier answer:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    [[self imageScrollView] willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
    [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
}

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    [[self imageScrollView] willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
    [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
}

Add that to your view controller (where [self imageScrollView] is your GMGridView instance.

from gmgridview.

kylefox avatar kylefox commented on June 9, 2024

@tonyarnold I'm a bit confused, how does that work? GMGridView doesn't seem to implement those selectors.

from gmgridview.

LauterAlsDerRest avatar LauterAlsDerRest commented on June 9, 2024

@kylefox asked myself the same question. All I can say is that my bandaid-fix works, but it would be better to only reupdate after a rotation and only when in horizontal-paging-mode for performance reasons. Maybe I will handle this, but at the moment it just works as it is for me.

from gmgridview.

kylefox avatar kylefox commented on June 9, 2024

@LauterAlsDerRest Interesting, I couldn't get your fix working either. Neither _scrollView nor currentPage existed. Are you using the master or develop brach?

from gmgridview.

LauterAlsDerRest avatar LauterAlsDerRest commented on June 9, 2024

@kylefox you have to add and track the currentPage as a property for yourself, sorry for not being clear. _scrollView is/was a property for the underlying scrollview in the master-branch.

from gmgridview.

tonyarnold avatar tonyarnold commented on June 9, 2024

@kylefox I'm working with the development branch. Perhaps these delegate methods have not made it into master yet.

from gmgridview.

kylefox avatar kylefox commented on June 9, 2024

@LauterAlsDerRest Great, thanks for clarifying.

@tonyarnold Weird, I'm using the development branch as well. Aren't those methods located on UIViewController, rather than UIScrollView (from which GMGridView inherits)? When I try this with the latest code from the develop branch Xcode tells me:

No visible @interface for 'GMGridView' declares the selector 'willRotateToInterfaceOrientation:duration:'

from gmgridview.

tonyarnold avatar tonyarnold commented on June 9, 2024

Completely my bad — you're correct. I was thinking about some other code, and somehow got it mixed up with GMGridView. Ignore me and go back to your lives… hands head in shame

from gmgridview.

kylefox avatar kylefox commented on June 9, 2024

@tonyarnold Drat! I hoped I was just overlooking something ;)

@gmoledina Any updates / suggestions for how to tackle this issue? I've been hacking on the GMGridView but cannot seem to find the source of this bug. Probably because of my newness to iOS :)

Any clues would be greatly appreciated, I really want to squash this issue!

from gmgridview.

kylefox avatar kylefox commented on June 9, 2024

For anyone else experiencing this issue, here's how you can patch it in your UIViewController:

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    CGPoint offset = CGPointMake(_currentPage * self.view.frame.size.height, 0);    
    [UIView
     animateWithDuration:duration
     animations:^{
         self.gridView.contentOffset = offset;
     }
     completion:nil];
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    CGFloat pageWidth = scrollView.frame.size.width;
    _currentPage = floor((scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
}

from gmgridview.

scompt avatar scompt commented on June 9, 2024

@kylefox's solution didn't work for me, so I came up with my own, also based on the develop branch:

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    id<GMGridViewLayoutStrategy> layoutStrategy = gridView.layoutStrategy;
    if([layoutStrategy isKindOfClass:[GMGridViewLayoutHorizontalPagedStrategy class]]) {
        GMGridViewLayoutHorizontalPagedStrategy *pagedStrategy = layoutStrategy;
        if(pagedStrategy.numberOfItemsPerPage != 0) {
            [gridView scrollToObjectAtIndex:_currentPage * pagedStrategy.numberOfItemsPerPage atScrollPosition:GMGridViewScrollPositionNone animated:YES];
        }
    }
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    CGFloat pageWidth = scrollView.frame.size.width;
    _currentPage = floor((scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
}

It's less than ideal because there's a bit of a jerk at the beginning of the rotation. View the rotation in the simulator with slow-motion animations and you'll see what I mean.

from gmgridview.

gmoledina avatar gmoledina commented on June 9, 2024

It's now fixed in the master branch.
Thank you all for sharing all the code !

from gmgridview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.