ikhsan / iainfinitegridview Goto Github PK
View Code? Open in Web Editor NEW[Deprecated] Infinite grid view with UITableView-esque data source methods
License: Other
[Deprecated] Infinite grid view with UITableView-esque data source methods
License: Other
When we set number of count to 0 it will crash on below code.
[self.dataSource numberOfGridsInInfiniteGridView:self] showing garbage value and app crash.
Can any one have solutions?
Thanks,
Dhaval
I was wondering if it was possible to have 3 total views, and to have the current one centered in the view like in this image below:
How would I be able to achieve this? I do not want all 3 views to be fully on screen. I just want the selected view to be centered and on screen, with the remaining 2 half-visible on the side.
How can i use IAInfiniteGridView like a simple ScrollView without circular and infinit?
I implemented this control line for line and it worked fine with paging and circular turned off. Then I tried to add this:
- (void)viewDidAppear:(BOOL)animated
{
[self.gridView setCircular:YES];
[self.gridView setPagingEnabled:YES];
[self.gridView jumpToIndex:0];
}
With some very strange results. The paging would work for the first scroll through but after that would gradually offset itself - more and more.
So I don't know what the issue is there, but a workaround is to add/change the initialization method in IAInfiniteGridView.m
- (void)initialization {
...
self.circular = YES;
self.paging = YES;
...
}
Maybe someone can shed some light onto what's going on.
First of all, thank you for the great component, I have small tip about improving memory usage for the infinite grid.
I noticed huge memory usage while profiling an app. using the infinite grid view.
When you scroll the infinite grid, method
tileGridsFromMinX:toMaxX:
which adds/removes views from one side using either
[lastGrid removeFromSuperview] or [firstGrid removeFromSuperview]
in ARC env. [lastGrid removeFromSuperview] doesn't release the view.
Similar problem I encountered with CorePlot: https://groups.google.com/forum/#!searchin/coreplot-discuss/memory/coreplot-discuss/nWui9VjnMtQ/er2FO3o9syYJ
If you do:
lastGrid = [self.visibleGrids lastObject];
while (lastGrid.frame.origin.x > maximumVisibleX) {
[lastGrid removeFromSuperview];
[self.visibleGrids removeLastObject];
[self.gridReusableQueue addObject:lastGrid];
lastGrid = nil;
lastGrid = [self.visibleGrids lastObject];
}
Memory usage is much more efficient. I've tested it in instruments, without lastGrid = nil I can easily reach 60Mb after 30 seconds of scrolling, with the line it increases but very slowly stays around 15Mb.
Is there any methot to reload views . Like [tableView reloadData];
Hello. I use your library and can't use standart scrollview.delegate method.
When i add infinitescrollview delegate to self^ pagination did.t work.
Why is scrollview content size 5 times bigger compared to the number of elements part of the scrolling view ?
self.contentSize = CGSizeMake(5 * totalGrids * gridSize.width, gridSize.height);
Hey!
Could you please guide me into setting it up with pre-determined UIView's only? I have 8 gridViews and for each one, I programmatically added code to set up the view with Images and Labels. It works fine for the first gridView, but as I scroll, all the other views I created disappeared, and when I try to scroll back to the first view, that one disappears as well. Any help with this would be much appreciated!
Here's some of my code:
(UIView *)infiniteGridView:(IAInfiniteGridView *)gridView forIndex:(NSInteger)gridIndex {
UIView *grid = [self.gridView dequeueReusableGrid];
CGRect frame = CGRectMake(0.0, 0.0, [self infiniteGridSize].width, [self infiniteGridSize].height);
CGRect imageframe = CGRectMake(-2, -7, 105, 105);
CGRect labelframe = CGRectMake(100, 47, 160, 40);
CGRect labelTframe = CGRectMake(39, 82, 50, 40);
CGRect windframe = CGRectMake(260, 50, 30, 30);
CGRect timeFrame = CGRectMake(160, 10, 70, 30);
CGRect windLframe = CGRectMake(292, 53, 60, 30);
if (gridIndex == 0) {
grid = [[UIView alloc] initWithFrame:frame];
BGView = [[UIImageView alloc] initWithFrame:frame];
BGView.contentMode = UIViewContentModeScaleAspectFill;
conditionsImageView = [[UIImageView alloc] initWithFrame:imageframe];
conditionsImageView.contentMode = UIViewContentModeScaleAspectFit;
wind1 = [[UIImageView alloc] initWithFrame:windframe];
wind1.contentMode = UIViewContentModeScaleAspectFit;
wind1.image = [UIImage imageNamed:@"WindT.png"];
labelW = [[UILabel alloc] initWithFrame:windLframe];
timeLabel1 = [[UILabel alloc] initWithFrame:timeFrame];
label = [[UILabel alloc] initWithFrame:labelframe];
labelT = [[UILabel alloc] initWithFrame:labelTframe];
labelT.backgroundColor = [UIColor clearColor];
labelW.backgroundColor = [UIColor clearColor];
label.backgroundColor = [UIColor clearColor];
timeLabel1.backgroundColor = [UIColor clearColor];
label.font = [UIFont fontWithName:@"League Gothic" size:27];
labelT.font = [UIFont fontWithName:@"League Gothic" size:30];
timeLabel1.font = [UIFont fontWithName:@"League Gothic" size:25];
labelW.font = [UIFont fontWithName:@"League Gothic" size:23];
[label setTextColor:[UIColor whiteColor]];
[timeLabel1 setTextColor:[UIColor whiteColor]];
[labelT setTextColor:[UIColor whiteColor]];
[labelW setTextColor:[UIColor whiteColor]];
[grid addSubview:BGView];
[grid addSubview:label];
[grid addSubview:wind1];
[grid addSubview:labelW];
[grid addSubview:labelT];
[grid addSubview:timeLabel1];
[grid addSubview:conditionsImageView];
}
if (gridIndex == 1) {
grid = [[UIView alloc] initWithFrame:frame];
BGView2 = [[UIImageView alloc] initWithFrame:frame];
BGView2.contentMode = UIViewContentModeScaleAspectFill;
conditionsImageView2 = [[UIImageView alloc] initWithFrame:imageframe];
conditionsImageView2.contentMode = UIViewContentModeScaleAspectFit;
wind2 = [[UIImageView alloc] initWithFrame:windframe];
wind2.contentMode = UIViewContentModeScaleAspectFit;
wind2.image = [UIImage imageNamed:@"WindT.png"];
label2W = [[UILabel alloc] initWithFrame:windLframe];
timeLabel2 = [[UILabel alloc] initWithFrame:timeFrame];
label2 = [[UILabel alloc] initWithFrame:labelframe];
label2T = [[UILabel alloc] initWithFrame:labelTframe];
label2T.backgroundColor = [UIColor clearColor];
label2W.backgroundColor = [UIColor clearColor];
label2.backgroundColor = [UIColor clearColor];
timeLabel2.backgroundColor = [UIColor clearColor];
label2.font = [UIFont fontWithName:@"League Gothic" size:27];
label2T.font = [UIFont fontWithName:@"League Gothic" size:30];
timeLabel2.font = [UIFont fontWithName:@"League Gothic" size:25];
label2W.font = [UIFont fontWithName:@"League Gothic" size:23];
[label2 setTextColor:[UIColor whiteColor]];
[timeLabel2 setTextColor:[UIColor whiteColor]];
[label2T setTextColor:[UIColor whiteColor]];
[label2W setTextColor:[UIColor whiteColor]];
[grid addSubview:BGView2];
[grid addSubview:label2];
[grid addSubview:wind2];
[grid addSubview:label2W];
[grid addSubview:label2T];
[grid addSubview:timeLabel2];
[grid addSubview:conditionsImageView2];
}
NSInteger mods = gridIndex % [self numberOfInfiniteGrids];
if (mods < 0) mods += [self numberOfInfiniteGrids];
CGFloat red = mods * (1 / (CGFloat)[self numberOfInfiniteGrids]);
grid.backgroundColor = [UIColor colorWithRed:red green:0.0 blue:0.0 alpha:1.0];
return grid;
}
(NSUInteger)numberOfInfiniteGrids {
return 2;
}
(CGSize)infiniteGridSize {
return CGSizeMake(320, 120);
}
Thanks!
The pageIndex number in
(void)infiniteGridView:(IAInfiniteGridView *)gridView didScrollToPage:(NSInteger)pageIndex
logs in decrementing number but sometimes the pageIndex logs in non succeeding number then continues to decrement again. Especially when circular is enabled.
No problem in incrementing pageIndex.
Btw, nice control. :D
I cannot figure out how to setup and add a IAInfiniteGridView programmatically. Am I doing anything wrong?
IAInfiniteGridView *gridView = [[IAInfiniteGridView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 568.0f)];
gridView.paging = YES;
gridView.hidden = NO;
gridView.dataSource = self;
gridView.gridDelegate = self;
self.gridView = gridView;
[self.view addSubview:self.gridView];
Would love to see that if possible :)
There is a method (jumpToIndex) to go directly to a page Index but without scrolling animation.
How to have this same method with scrolling animation ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.