Comments (8)
Absolutely, I've run into this now so I'll see what I can do and push it back.
from gmgridview.
You can also get the visible cells like this:
CGPoint contentOffset = ((UIScrollView*)[[gridView subviews]objectAtIndex:0]).contentOffset;
for (GMGridViewCell *view in [[[gridView subviews]objectAtIndex:0] subviews])
{
...
}
But everytime you enter sorting mode the cells order seems to change in the subviews array. So this is not best solution. I'll try to make itemSubviews public and see if its better for my purpose.
Maybe I'll create a getCellsInRange Method or something like that, where you can also get a smaller amount of cells than the visible ones. Could be useful for some fancy animations. :)
btw. How do i make code tags in a comment?
from gmgridview.
I reached to get them like this :
Add @property (nonatomic) int index;
to GMGridViewCell.h and @synthesize index;
to his .m file:
Then in -(GMGridViewCell *)GMGridView:(GMGridView *)gridView cellForItemAtIndex:(NSInteger)index
add cell.index=index;
before return cell;
.
All you have to do now is adding a public method to GMGridView:
-(NSArray *)indexPathsForVisibleRows;
-(NSArray *)indexPathsForVisibleRows{
NSMutableArray *lc_array = [[NSMutableArray alloc] init];
for(int i=0;i<[self.subviews count];i++){
if(CGRectIntersectsRect(self.bounds, [[self.subviews objectAtIndex:i] frame]) && [[self.subviews objectAtIndex:i] isKindOfClass:[GMGridViewCell class]]){
GMGridViewCell *subview = (GMGridViewCell *)[self.subviews objectAtIndex:i];
[lc_array addObject:[NSIndexPath indexPathForRow:subview.index inSection:0]];
}
}
return lc_array;
}
from gmgridview.
The above solution "indexPathsForVisibleRows" for getting count of visible cells gives wrong results on orientation change. Unable to find the solution though.
from gmgridview.
Sorry I haven't noticed that cause I'm reloading data on rotation
from gmgridview.
I too am reloading data on orientation change but the count comes wrong for me though.
from gmgridview.
I can't reproduce your problem. I'm using this method in order to use apple's lazy technique for cell' images. I always get the same association image/cell, rotation doesn't alter anything.
from gmgridview.
My problem persists when GMGridView is scrolled to the end when the GMGridView is partially filled...
The scenario is as follows :
Datasource count = 44
Potrait mode = 2 columns * 7 rows = 14 cells
Landscape mode = 3 columns * 5 rows = 15 cells
Potrait mode
=> page 1 = count is 1 to 14. ==> 14 cells
=> page 2 = count is 15 to 28. ==> 14 cells
=> page 3 = count is 29 to 42. ==> 14 cells
=> page 4 = count is 43 to 44. ==> 2 cells
Landscape mode
=> page 1 = count is 1 to 15. ==> 15 cells
=> page 2 = count is 16 to 30. ==> 15 cells
=> page 3 = count is 31 to 44. ==> 14 cells
Now when I scroll to the 3rd page in landscape mode and then change the orientation, I reach the
to the 4th page but with count of 3rd page.
Also the [self.subViews count] gives me a different value each time the "indexPathsForVisibleRows" method is called. So I am considering "[[self itemSubviews] count]" as my counter for the for loop.
My grid view frame is ===> _gmGridView.frame=CGRectMake(10, 84, 1004, 565); for landscape
_gmGridView.frame=CGRectMake(10, 84, 748, 820); for potrait
Also the item cell size is as follows
- (CGSize)GMGridView:(GMGridView *)gridView sizeForItemsInInterfaceOrientation:(UIInterfaceOrientation)orientation
{
return CGSizeMake(_gmGridView.frame.size.width/_numberOfColumn, _gmGridView.frame.size.height/_numberOfRowVisible);
}
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.