Coder Social home page Coder Social logo

gmoledina / gmgridview Goto Github PK

View Code? Open in Web Editor NEW
2.3K 2.3K 515.0 251 KB

A performant Grid-View for iOS (iPhone/iPad) that allows sorting of views with gestures (the user can move the items with his finger to sort them) and pinching/rotating/panning gestures allow the user to play with the view and toggle from the cellview to a fullsize display.

License: MIT License

Objective-C 98.99% C 1.01%

gmgridview's People

Contributors

dennda avatar futuretap avatar gmoledina avatar jcouture avatar pguitard avatar pongpong avatar rantav avatar ricsantos avatar soleares avatar steipete avatar tonyarnold avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gmgridview's Issues

Orientation change layout bugs

After finding this project I decided to test it and found some orientation bugs which seem quite nasty. Using an iPad (tested in simulator and hardware, 4.x and 5.x) launch the demo in landscape I scroll enough so that cell A50 is on the top of the screen. Then rotate to landscape and see a blank row, plus the items displayed don't match the previously visible ones. I've recorded a video so you can check it out: http://dl.dropbox.com/u/145894/t/gmgridview_rotation_bug/flick.mp4 (543K).

Also, another time I tried going slowly step by step to see if the problem is with the flicking gesture and found the same odd result. In this recording I also happen to touch incorrectly positioned items of different size after the rotation: http://dl.dropbox.com/u/145894/t/gmgridview_rotation_bug/steps.mp4 (721K).

This really turned me off after reading the nice feature list.

insertObjectAtIndex: mixes up all the following cells

Data is changed first, that calls fetchedResultsController didChangeObject: method. When I use there insertObjectAtIndex:(NSInteger)index method to put a new item in the gridview (actually in the horizontal layout, if matters) all the following cells are mixed up. It seems that the cell at index position moves to the end of the gridview so that the cell layout does not correlate to the data anymore.

Optimization breaks app

The optimization from issue #62 is breaking my app.

My app is designed so that I load the data for the cells in a background thread and then call reloadData on the main thread to update the contents of the cells. With this optimization in place, I get a page of empty cells.

When I call reloadData, it looks like the optimization is correctly exiting loadRequiredItems early, but then loadRequiredItems is being called again from layoutSubviewsWithAnimation and not exiting early, causing the incorrect loading.

Let me know if there's any additional information I can provide.

Delegate method for when cells will be displated

It would be really nice to have something that tells the when a cell is about to be drawn on the screen. Methods such as:

willDisplayCell:atIndex:
didDisplayCell:atIndex:

(Similar to tableView:willDisplayCell:forRowAtIndexPath: in UITableViewDelegate's)

Here's an example use case:

I am using GMGridView to display full-screen photos in a single row. The view controller allows captions (a UILabel on each cell's view) to be toggled on/off. I need a way to either show or hide this label just before the cell comes into view to ensure that the state is correct.

Using cellForItemAtIndex doesn't work, because the current, previous and next cells are all pre-loaded, so their state is incorrect. I've also tried calling [gridView reloadData] to force invalidate all the cells, but that causes the images to flicker.

Any suggestions?

Updating cell content using GCD causes stuttering while scrolling

When I use GCD to load cell content (in my case: loading thumbnail images from file or from a cache and adding a few UILabels) the scrolling performance is very noticably impaired. The UI updates are happening while the scrollview is still scrolling (either inertia, or finger not released) which is not commonly the case (see for example Safari) but should instead wait until the scrollview stopped scrolling and only then perform all the UI updates.

I have no idea, why its doing it "wrong". Any tips, or is this expected behaviour?

Folders

Would be nice to have a feature to drag two or more items to a "folder" element which basically is another grid view.

crashed in UIGestureRecognizerStateBegan

sometimes,it may be crash....

GMGridView.m,line 1071.

    case UIGestureRecognizerStateBegan:
    {
        CGPoint locationTouch = [_tapGesture locationInView:_scrollView];
        NSInteger position = [self.layoutStrategy itemPositionFromLocation:locationTouch];

        if (position != GMGV_INVALID_POSITION) 
        {
            [(GMGridViewCell*)[self.itemSubviews objectAtIndex:position] setSelected:YES];
        }
        break;
    }

should change to:

    case UIGestureRecognizerStateBegan:
    {
        CGPoint locationTouch = [_tapGesture locationInView:_scrollView];
        NSInteger position = [self.layoutStrategy itemPositionFromLocation:locationTouch];

        if (position != GMGV_INVALID_POSITION && [self.itemSubviews count]>position) 
        {
            [(GMGridViewCell*)[self.itemSubviews objectAtIndex:position] setSelected:YES];
        }
        break;
    }

then fix it.

Progress Bar disappeared

I tried to implement GMGridView to my existing project. It is a kiosk for ebooks and when user tap on a cover download begins. I've added book covers as subviews to cells and everything works perfect until user scrolls to bottom. When downloading cell disappears as user scroll progress bar vanishes. I guess GMGridView automatically update cell content and that cause the problem. Downloading class and cover view speaks via notification center. Do you suggest a solution to this problem. Thanks in advance.

entering sorting mode changes position of view to sort in data array even if the actual position in the grid is not changed.

Hi Gulam,
I noticed, that your framework seems to change the position of the item you select when you want to sort it, even if you didn't change the position of the item.
It is always added to the end of the array as it seems to me.
I found this out, because i am animation all icons displayed by the grid in an order given by the order in the data array.
When i enter sorting mode for one icon and dont move it but disable sorting mode by lifting my finger up again without moving, the item is animated as last and not in the order it should.
Is this behaviour intended, or is this a bug?
If it is intended, can you give me some hint how i can avoid it?
Of course i could iterate through the whole array everytime before i animate an item and pick the correct item by its tag, but that would be very expensive.
Maybe you can give me some hint how i can do this better.

Greetings
and thanx again for this framework, which already saved me a lot of work. :)

Maverick1st

Only loading 36 Images [Bug]

Hi to everyone,

I am trying to implement GMGriridView to my app. But i need that it shows allot of images [max 100] but after the image 36 it start repeating the first 36 images. Here is my code

GMGridViewCell *cell = [gridView dequeueReusableCell];

if (!cell) {
    cell = [[GMGridViewCell alloc] init];

    UIImageView *image = [[UIImageView alloc] init];
    NSString *img = [NSString stringWithFormat:@"%@.png", [_data objectAtIndex:index]];
    NSLog(@"%@", img);
    image.image = [UIImage imageNamed:img];

    cell.contentView = image;
}

[[cell.contentView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];

return cell;

Edit:

Also when you scroll fast the images change the order :S

Fullscreen on tap

Would be nice to have some public method to call on tap to put a cell in fullscreen.

Fade on rotate / fix rotation issues

Rotation makes some really crazy animations, definitely not what I'm expecting.
Also, I'd propose that you'll make it at least an option to make a "fade" transition on rotation - much like iOS'es Springboard.
While wildly moving cells is "cool" I get why Apple decided against it - it's much more quiet when it's just fading.
Any idea how I could do this? A reload in willAnimate? And then adding a CAAnimation for the fade? Should be a property of the view imho...

Screenshots:
http://cl.ly/1M3M2y2V0V1X1S2a091i
http://cl.ly/1m1v3a0g2m392N3l0C1p

Incorrect contentSize calculation in GMGridViewLayoutHorizontalPagedStrategy

IMO there's a small error when calculating the _contentSize (and specifically the width) when minEdgeInsets sets only the left inset but not the right inset. This is probably the same case for top+bottom.

For example:

  gmGridView.minEdgeInsets = UIEdgeInsetsMake(0, 20, 0, 0);

This results in a grid nicely centered (with 20px from each side, left and right), but when the grid has many pages (more than 20 in my testing) then not all pages are displayed.
To fix this specific case I do:

  gmGridView.minEdgeInsets = UIEdgeInsetsMake(0, 20, 0, 20);

However, this shows that probably even though the grid is centered for each page, the right edges insets aren't taken into proper consideration when calculating the entire grid width so that when the number are large enough, this error results in some of the last pages missing.
BTW, I did not set the centered property.

The faulty code is probably at GMGridViewLayoutStrategies.m, line 400

_contentSize = CGSizeMake((onePageSize.width  + self.edgeInsets.left + self.edgeInsets.right) * self.numberOfPages, 
                          onePageSize.height + self.edgeInsets.top  + self.edgeInsets.bottom);

self.edgeInsets.right is 0 so this results in a wrong calculation.

Really nice component!

Just want to say this is an awesome little component, I've been looking around for awhile now and have only found 1 component that is on par with your implementation and that is KKGridView, though to get it to archive is (static library madness,at least for me) impossible, so suffice it to say, that when I found yours and tested it out and saw how good it worked I was happy and relieved all at once! :) There is one thing I would suggest changing and that is the deleteButton in GMGridViewCell+Extended.h as it may clash with an already existing deleteButton property name in a custom GMGridViewCell subclass. Incidentally, this happened to me and left me scratching my head for a half an hour wondering why my deleteButton wasn't showing up. Maybe some naming convention would help, or at least a warning in the documentation to not define "reserved" property names in GridViewCell subclasses, i.e. deleteButton :). Keep up the good work and when I get some time I will most definitely try to contribute something! :)

Please add semantic version tags.

I’ve recently added GMGridView to the CocoaPods package manager repo.

CocoaPods is a tool for managing dependencies for OSX and iOS Xcode projects and provides a central repository for iOS/OSX libraries. This makes adding libraries to a project and updating them extremely easy and it will help users to resolve dependencies of the libraries they use.

However, GMGridView doesn't have version tags. I’ve added the current HEAD as version 0.0.1, but a version tag will make dependency resolution much easier.

Semantic version tags (instead of plain commit hashes/revisions) allow for resolution of cross-dependencies.

When data source changes, reloadData not functioning?

I'm building a data source from different JSON API feeds. However when I invoke reloadData on the gridView the data does not change. I'm sure I've checked everything like the content of the data source, etc. but I'm left scratching my head. Is there some kind of cell caching going on that needs to be broke to accept the new data?

Thanks for what I feel is the best GridView out there ;-)

Visible cells nice to have

It would be convenient for a public method on gridView that returns the currently visible cells. Right now I have resorted to making the itemSubviews method public instead of private. Anyone concur with me on this??

strange flickering in the simulator

have you noticed the strange flickering when cells are scrolled in the simulator?
it's not visible on the device, but I'm really curious why this might happen.

Layout: Horizontal + Vertical

I've looking for a Grid to do an App but the catch with my concept is that it will grow Horizontally and Vertically as content is available.

Maybe there's already a way to achieve this here but i'm not aware.

To put it in context:
lets say I have a TV Guide, the App doesn't know how many channels (Y axis) nor the timeline width (time has no bounds).

The user would also be able to filter the channels so once the data about channels is obtained there is no certainty the Y axis will have the same number of rows as it could decrease (And the idea is not to set a new grid but make a smooth transition)

Also the user would be able to add rss like urls so there might be more channels than the known.

That's just an example but you get the idea of a Grid that has no bounds, right?

Is there a way to do it currently? or should I wait? or develop?

[GMGridView insertObjectAtIndex] wrong assertion

Maybe I'm not reading it right, but it seems that insertObjectAtIndex has a wrong assertion at the beginning.

- (void)insertObjectAtIndex:(NSInteger)index
{
    NSAssert((index >= 0 && index <= _numberTotalItems), @"Invalid index specified");

When calling insertObjectAtIndex then it's expected that since a new object is inserted, then index is > than _numberTotalItems (the number of total items should increase). That's at least how things work in UITableViewController, so I expected similar behavior here as well.
Maybe my expectation is not in place though... what do you think?

Feature Request: Infinite scrolling

Great component, would it be possible to add infinite scrolling?
In my case I'd need it cause I'm downloading pics from the web but I want to add more to the grid only if the users scrolls to the bottom.
Thanks

adding an UIImageView to cell.contentView crash memory leaks

hello gmoledina,

great grid!!! its exactly what i need the problem is that 2 weeks i am stuck with a memory problem!!!

i am adding a UIImageView to cell.contentView and the app crashes after some scrolling.

is there a way to add an image to cells without problems?

if not so whats the reason for using it if it can't manage views on it except labels?

i really need an answer as soon as you can, Please? :)

i really appreciate your help! thanks,

Refael.S

Basic documentation

Hi, I'm relatively new to iOS and one thing I've noticed is that third-party libraries (like GMGridView) all seem to take a different approach to integration. Sometimes I add the Xcode project to my own workspace, other times I add a static library (*.a), etc.

I can't for the life of me figure out how to add GMGridView to my own Xcode project. It would be awesome if there was a quick note about how to integrate it into one's Xcode project.

I tried copying the "API" files in the demo, but I got build errors. Any help would be greatly appreciated!

Sections and titles

Has anyone extended this to have multiple sections and section titles (like the iPad iTunes and AppStore apps)?

iOS 4 pinch gesture problem

Thanks for great framework!

First, I'm not comfortable with English.
Hope you understand my English.

In iOS 5, there is no pinch problem. It worked fine.
In iOS 4, when I pinched out the cell it worked and fullsize-view appeared,
but pinched in the fullsize-view to remove, I didn't make it.
When I pinched out slightly so that pinch gesture is triggered and pinched in again, then it worked.

Would you check this out please?

Enable gestures during editing

Would be nice to have some public method to enable all gestures when enter editing mode, so that user could move item by long press,or tap to stop editing.

Reload cell item with a new size

Is possible to change the size of an item dinamically? I've tried to reload a cell using reloadObjectAtIndex and changing the size inside the datasource but nothing happends.

numberOfItemsInGMGridView

I have 2 GMGridView's, how to return different numberOfItemsInGMGridView and how do I know wich cell is pressed in each GMGridView ?
Keep up the great work.

Thanks in advance
Antonios

Adding a UIButton to GMGridViewCell's contentView

First of all, thank you for sharing this fantastic component. It's very cool.

Now, I'm facing a little problem and I don't know to fix it.

I've created a custom UIView called CustomView. An instance of this view is assigned to the contentView property of GMGridViewCell class within cellForItemAtIndex method.

if(!cell) {

    // create CustomView here...
    cell.contentView = customView;
}

The custom view has a UIButton as a subview. The problem is that the button seems to not respond to tap events since they are redirected to GMGridView.

Is it possible to overcome this problem? Thank you in advance.

Scrolling seems to stop randomly on iOS4

Sorry to bug you again ;)

You're using a lot of UIView animation blocks. That's not a good idea on iOS4, especially not when you use an animation while the scrollview is decelerating. Note that layoutSubviews is called like crazy when you scroll, and currently you're creating two blocks on each run.

This works fine in iOS5/iPad2 but it's too slow for iO4/iPad1.

I've added a patch in my branch that removes the animation blocks when called form layoutSubviews, this fixes the problem.

Accessor to get current Cells

In AQGridView, i quite heavily used cellForItemAtIndex: and visibleCells.

Mainly to add some custom fancy animation, and also to change cells on the fly, w/o needing the grid to reload every one if them. How hard would it be to add those methods? As a minimum solution, i would also be ok just just get the CGRect of a cellIndex.

Background image view for each row / column

Hi there!

Really nice view you've developed!! For me it is the most interesting grid view I have found at the moment.

Is it possible to specify a view for each row or column?

I tried with something like this:
...scrollView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"image.png"]];
but it seems to have very bad performance.

Compiler Linker Error with XCode 4.2.1

I have included the API folder in my project and added the API folder to the Build Settings - "header search paths" (hope that's OK? ) - and then I used the GridView classes in one of my own files. Now, the project won't compile. I get these errors :-

Apple Mach-O Linker(Id) Error
"OBJC_CLASS$_GMGridViewCell", referenced from:

As you can tell, I am new to iOS development but I am hoping someone can tell me how to fix this compiler error?

Thanks in advance.

Horizontal Paging with Previews Layout Strategy

It would cool to have a layout strategy that supports previews. Though this can easily be done by subclassing UIScrollView, GMGridView has some really great additions like lazy loading and UITableView like API.

I'm talking about something like this:

ScrollView

I don't think it will be to hard to implement, a horizontal paging layout strategy already exists, only the "preview" support (of the left and right view) must be implemented.

Replicate SpringBoard behavior

Hey,

first up kudos for the library. It rocks!

I'd like to replicate the SpringBoard behavior in the following way:

  • In "normal" mode I am not able to move or delete cells
  • When touching and holding a cell for x secs the grid view switches to "editing" mode (all cells wiggling), where I am able to move AND/OR delete cells (the delete button shows for all cells). Of course I would need an Edit/Done button in the navigation bar to finish the editing mode.

Is it possible to produce this behavior with the current code? If not, I'll dig in :)

Using GMGridView without ARC

Maybe it's the wrong place to write, but I would like to know if it is possible to use your component without ARC. Thank you in advance.

Stop scrolling before recognizing a cell touch

Currently GMGridView has a very annoying behavior that it recognizes touches that are only intended to end scrolling as a proper cell touch. I'm gonna look into it, but I'm really wondering why this doesn't annoy anyone else?

In the demo you can see that "DId tap at index" is written as soon as I stop scrolling. Touching a grid item should only ever be possible when no scroll movement is there.

Adding pull-to-reload functionality

First of all, awesome component. I've been able to get up and running very quickly with it.

I'm interested in adding pull-to-reload to the grid wanted to hear what your opinion is about implementing it. The easiest way to add it would be to modify the UIScrollViewDelegate methods in GMGridView, but I'm wondering if there might be a way to add it without having to implement it directly in GMGridView. Perhaps as a wrapper around the existing UIScrollViewDelegate methods. Do you have any ideas?

Different sized cells.

I would like to contribute to the project by adding support for mixed size cells.

Originally thinking in multiples of the smalles view; as to not change the ordering or anything like that.

I am analyzing the code right now but do you have any heads up as to how to go about implementing this?

Is it in your plans to implement it (so we can work together)?

It would basically allow an item that is three columns high mixed with 1x1 cells.

Add wiggle to edit mode

It would be nice feature to have individual cells wiggle in edit mode! Like the icons in SpringBoard

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.