Comments (20)
How exactly are they misaligned? Can you provide screenshots?
from gmgridview.
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.
Yup I'm able to reproduce it. Will be fixed soon.
from gmgridview.
I think I'm experiencing the same issue (see screenshot). Any updates on this issue? Thanks!
from gmgridview.
Next in my list !
Out of curiosity, what's this app? Already in the appStore?
from gmgridview.
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.
@gmoledina how'd you go with this error? I'm seeing it while using the development branch on an iPhone app.
from gmgridview.
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.
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.
@tonyarnold I'm a bit confused, how does that work? GMGridView
doesn't seem to implement those selectors.
from gmgridview.
@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.
@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.
@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.
@kylefox I'm working with the development branch. Perhaps these delegate methods have not made it into master yet.
from gmgridview.
@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.
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.
@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.
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.
@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.
It's now fixed in the master branch.
Thank you all for sharing all the code !
from gmgridview.
Related Issues (20)
- How can items drag in both the directions Left to Right and Right to Left ?
- GMGridView reloadData does not refresh view
- Archives has does not contain a single–bundle application or contains multiple products
- iOS 7 Horizontal strategy content size HOT 2
- No document about how to use this control
- if cell width is quite different, grid will show wrong cell when rotating
- ios 5.1 and lower issue HOT 1
- Grid cell want to draw from top HOT 1
- scrollToObjectAtIndex is not working properly when paging is enabled HOT 1
- memory problem - not released/reclaimed HOT 1
- another mem issue
- GMGrid Cell Alignment Issue
- Image stuck on screen
- Sort Help required!
- gridview.edit=yes,how to use sortingdelegate?
- index = -2147483648
- Maybe you can join a group function
- Button not working in subview GMGridviewCell
- Image link in README.md is broken
- animation repeat count doesn't work in GMGridViewCell
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gmgridview.