kolinkrewinkel / kkgridview Goto Github PK
View Code? Open in Web Editor NEWDeprecated: Grid view library for iOS.
Home Page: https://github.com/kolinkrewinkel/KKGridView
License: Other
Deprecated: Grid view library for iOS.
Home Page: https://github.com/kolinkrewinkel/KKGridView
License: Other
Just prevent calling of -setNeedsLayout between -beginUpdates and -endUpdates, just adding them to the stack.
- (void)beginUpdates;
- (void)endUpdates;
Launch on iOS 5 simulator, scroll to bottom, EXEC_BAD_ACCESS
(void)_cleanupCells
{
const CGRect visibleBounds = { self.contentOffset, self.bounds.size };
[_visibleCells enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { <<<<<<<<<EXEC_BAD_ACCESS
KKGridViewCell *cell = (KKGridViewCell *)obj;
KKIndexPath *indexPath = (KKIndexPath *)key;
if (!KKCGRectIntersectsRectVertically(cell.frame, visibleBounds)) {
[cell removeFromSuperview];
[_visibleCells removeObjectForKey:indexPath];
[self _enqueueCell:cell withIdentifier:cell.reuseIdentifier];
}
}];
}
#0 0x0140009f in objc_msgSend ()
#1 0x00020000 in pvars ()
#2 0x00007943 in __27-[KKGridView _cleanupCells]_block_invoke_0 at /Users/dxclancy/Downloads/kolinkrewinkel-KKGridView-88e2e5d/KKGridView/KKGridView.mm:471
#3 0x01256398 in ____NSDictionaryEnumerate_block_invoke_4 ()
#4 0x011715e5 in CFBasicHashApply ()
#5 0x011ee51a in __NSDictionaryEnumerate ()
#6 0x011ee065 in -NSDictionary enumerateKeysAndObjectsUsingBlock:
#7 0x000078c4 in -KKGridView _cleanupCells
#8 0x00006c11 in -KKGridView _layoutVisibleCells
#9 0x00004ce0 in -KKGridView _layoutGridView
#10 0x00004c77 in -KKGridView layoutSubviews
#11 0x002e9101 in -UIView(CALayerDelegate) layoutSublayersOfLayer:
#12 0x001bf0d7 in -CALayer layoutSublayers
#13 0x001c9a70 in CA::Layer::layout_if_needed(CA::Transaction*) ()
#14 0x00151cd7 in CA::Context::commit_transaction(CA::Transaction*) ()
#15 0x00153512 in CA::Transaction::commit() ()
#16 0x000f8470 in CA::Transaction::flush_transaction() ()
#17 0x001e8747 in CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long) ()
#18 0x001e9763 in CA::Display::EmulatorDisplayLink::callback(CFRunLoopTimer, void) ()
#19 0x0122a383 in CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION ()
#20 0x0122b814 in __CFRunLoopDoTimer ()
#21 0x011841e6 in __CFRunLoopRun ()
#22 0x01183750 in CFRunLoopRunSpecific ()
#23 0x01183671 in CFRunLoopRunInMode ()
#24 0x021280c3 in GSEventRunModal ()
#25 0x02128188 in GSEventRun ()
#26 0x002aac29 in UIApplicationMain ()
#27 0x00001c5b in main ()
#28 0x00001c05 in start ()
I am trying to have an image in the background of the gridview, so I thought the following code would hide the control background and allow the image to show through similar to a tableview but seems to have no affect
[self.gridView.backgroundView setHidden: YES];
My iOS coding skills are basic so I might be completely wrong, if there is a better a way then I am happy to learn.
If a title is provided in -gridView:titleForHeaderInSection:
or its corresponding footer call, create default-ish looking headers automatically w/ a default height of 27pt.
In addition to delegate/datasource pattern, e.g for batch updates (similar to UIView animatieWithDuration:block:), cellForItemAtIndexPath
How to? overflow items in sections goes to next page instead of have the grid box list below to next row?
This will be similar to Pulse app where the overflow grid items in section on the page column inside the section instead of fall below the current row.
Is this feature supported?
Am I correct that KKGridView is for iOS4 upwards? It works in the 4.3 Simulator, but haven't yet looked into it closely.
Is there a way to deselect grid cells once tapped, as in a table view?
I think our reload method isn't firing with the navigation controller or something
Hi,
Just been playing around with the demo app. There's a call in setCellBlock to assign the background colour, but changing this doesn't have any effect. I've found the only way currently to set the background colour correctly is to change it in KKGridView, in the layoutsubviews method (I've changed it to red here):
if (_selected) {
_contentView.backgroundColor = [UIColor clearColor];
_contentView.opaque = NO;
} else {
_contentView.backgroundColor = [UIColor redColor];
}
Cheers,
Paul
KKGridView currently ignores this. This is annoying.
We need to rework some code in - (void)_performUpdate:(KKGridViewUpdate *)update withVisiblePaths:(NSArray *)visiblePaths
See screenshot, if I press + rapidly in the example project:
Will Display Item, Did deselect item, etc:
- (void)gridView:(KKGridView *)gridView willDisplayItem:(XGridViewItem *)item forIndexPath:(KKIndexPath *)indexPath;
- (void)gridView:(KKGridView *)gridView didDeselectAtItemIndexPath:(KKIndexPath *)indexPath;
I don't understand why you replaced the standard cocoa convention of dataSource and delegate protocols with a block per method. This makes the calling code much uglier to write. Please consider reinstating the original protocol methods.
ps If you really want to use blocks for every method, then a better approach would be to create a proxy object that implements KKGridViewDataSource and has a property for each method block.
I'm wondering what people think about breaking -_layoutGridView
into a few smaller methods. The reason I suggest this is that I think it's rapidly becoming “write-once, read-never” code. If the consensus is that this would be a good idea, I'm happy to tackle it.
via -insertItemsAtIndexPaths:
I have compiled libKKGridView.a, I want to use in Xcode 4.0 (ios SDK 4.x), I think the demo code using ios 5.0. Is there example that use ios 4.x?
Hi guys,
i finally have time to look into KKGridView, and already found/working on some issues.
I'm curious, what's the reasoning behind renderQueue and the dispatch_sync? (_layoutGridView, KKGridView.mm)
I've never seen such a pattern - AFAIK you're not allowed to make UIKit-changes except in the main thread, so we're already guaranteed that no two render operations run at the same time. Am I overlooking sth?
When calling:
- (void)insertItemsAtIndexPaths:(NSArray *)indexPaths withAnimation:(KKGridViewAnimation)animation;
there is an EXC_BAD_ACCESS on line 483
CGFloat footerHeight = _footerHeights[section];
in KKGridView.mm
As a temporary measure, I create an empty UIView for the header and the footer and specify the header and footer view height as 0.0f.
(Sorry, I'm new to GitHub so bear with me while I learn how to use this thing...)
I think KKGridView has great feature. Could you create google group for KKGridView? this will expand the usage of KKGridView
auto select touch's view, then asynchronously do the array/set management stuff
When rotating, I would expect the same cells to be shown when rotating from portrait to landscape and vice versa (or at least something close to that).
Seems the scrollview position gets way off. Tested by adding numbered labels to demo and adding 100 or so cells to first section.
I added some code to "fix" to the rotation delegates, but it's a hack at best.
Am I missing something here? For the end-user, if they see images in the visible cells in portrait, they should see those same images when rotating to landscape (within a certain bounds of course), right?
I'm noticing that footer views stick to the bottom of the screen (analogous to header view behavior), whereas in UITableView, footer views are not sticky. I wonder whether it might not be better to allow this as an option, but have the default behavior be non-sticky. Thoughts?
This goes along with #16, since a default-ish looking section footer label would look rather silly if it were stuck to the bottom.
You write in README: "Remember that your project need not use ARC to include KKGridView"
But this is not excactly true - you can't use it (even using binary file built with LLVM 3.0) in projects which are building with LLVM 2.x, since you have to include headers which contain new ARC keywords like 'strong', 'unsafe_unretained' etc. If I comment property definitions with new keywords in KKGridView headers my project builds successfully and grid is working. So it would be nice if some condition vars will be present to allow users with legacy compilers use this library.
Thanks!
• See UITableView for guidance
via -deleteItemsAtIndexPaths:withAnimation:
See UITableView for guidance.
The reload data call should actually reload data (to match UITableView conventions).
What it is currently appears to be a reset data call.
I added a _layoutVisibleCells call at the end of the reload data method to accomplish this.
Would that break other areas of the grid? I see reloadData called when cell sizes/spacing is set. Should there be an internal "Reset" method that can be used in those other methods, and also in the reloadData call?
Not sure i fully understand the implications.
Anyone think of an alternative to showing a stupid alertview in the demo as confirmation?
I'mma going to fix this. brb :)
My thoughts are that KKGridViewHeader
ought to be a private, non-consumer-facing class which wraps the UIView
which the API consumer provides.
Excellent framework, beats just about any comparable component out there even if it is still in its infancy. A fat static library would be really,really nice. I have been trying to include this project as a dependancy works with sim and device but blows up hard on archive. I have my own static lib which compiles just fine for all build types. So either a nice README of how to integrate this project as a dependancy would be stellar or even better....a fat static library. :)
I'd love to have some comments, especially on the trickier parts of the code - e.g. in KKGridView.mm there are, besides _layoutAccessories, no comments at all.
I know I'm to blame for this but I wanted to implement a correct behaviour first before I start to optimize. I'm not sure how this method is implemented internally but I expect the high amount of calls to sendToBack to be rather slow.
Goal is to get currently sticking header/footer to be on top of other views. A simple bringSubviewToFront isn't working, since it then is on top of the UIScrollView - scrollIndicator (should we open a rdar/bug for this?).
Maybe bringToFront + exchange with second-frontmost subview (which should be the scrollIndicator then) works.
Thoughts?
Selection gets messed up - setAllowmultipleediting handler should be used to clear or something.. Description in commit message from around 5 pm
In the wiki say that this could work as the springboard.
I can draw the cells, but adding new subviews on the cells block the selection code, and the delegates are not fired for selection.
Also, I try loading from a nib with the same results (the cells are show, but not selection work).
...not quite there yet ;)
Since there are multiple cells per row, I propose renaming this method -gridView:cellForItemAtIndexPath:
. Thoughts?
via -reloadItemsAtIndexPaths: This should be a piece of cake with a for loop or enumeration and calling -setNeedsDisplay.
With this code:
- (void)loadView
{
[super loadView];
self.gridView.cellSize = CGSizeMake(240.f, 180.f);
self.gridView.scrollsToTop = YES;
self.gridView.showsVerticalScrollIndicator = YES;
self.gridView.cellPadding = CGSizeMake(12.f, 30.f);
self.gridView.allowsMultipleSelection = NO;
}
#pragma mark KKGridView DataSource
- (NSUInteger)numberOfSectionsInGridView:(KKGridView *)gridView
{
return 1;
}
- (NSUInteger)gridView:(KKGridView *)gridView numberOfItemsInSection:(NSUInteger)section
{
return [self.boards count];
}
- (KKGridViewCell *)gridView:(KKGridView *)_gridView cellForItemAtIndexPath:(KKIndexPath *)indexPath
{
NSString *cellID = [HomeCellView cellIdentifier];
HomeCellView *cell = (HomeCellView *)[gridView dequeueReusableCellWithIdentifier:cellID];
if (cell == nil) {
/*[[NSBundle mainBundle] loadNibNamed:@"HomeCell" owner:self options:nil];
cell = self.homeCell;
self.homeCell = nil;*/
cell = [[HomeCellView alloc] initWithFrame:CGRectMake(0,0, HOME_WIDTH, HOME_HEIGTH)];
cell.title = [[UILabel alloc] initWithFrame:CGRectMake(0,0, HOME_WIDTH, 36)];
cell.backgroundColor = [UIColor grayColor];
cell.title.backgroundColor = [UIColor blackColor];
cell.title.opaque = YES;
[cell addSubview:cell.title];
}
Board *b = [self.boards objectAtIndex:indexPath.index];
cell.title.text = b.name;
return cell;
}
- (void)gridView:(KKGridView *)gridView didSelectItemAtIndexPath:(KKIndexPath *)indexPath {
ALog(@"1");
}
In this method:
- (void)_cleanupCells
{
const CGRect visibleBounds = { self.contentOffset, self.bounds.size };
[_visibleCells enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
KKGridViewCell *cell = (KKGridViewCell *)obj;
KKIndexPath *indexPath = (KKIndexPath *)key;
if (!KKCGRectIntersectsRectVertically(cell.frame, visibleBounds)) {
[cell removeFromSuperview];
[_visibleCells removeObjectForKey:indexPath];
[self _enqueueCell:cell withIdentifier:cell.reuseIdentifier]; < -- NIL!!!
}
}];
}
I run under iOS 5 simulator. The project use ARC. When I scroll pass the visible cells I get :
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary setObject:forKey:]: attempt to insert nil key'
*** First throw call stack:
(0x1df6082 0x1f87d0a 0x1d9eaa8 0x1d9ea19 0x1df52e9 0x1a5c8 0x1a25c 0x19753 0x1df5958 0x1d19aad 0x1d91c36 0x1d918ad 0x1d917f5 0x19520 0x18599 0x15e80 0x15e17 0xede009 0x1df7ea2 0xdbd9d1 0xdc78cb 0xd4e079 0xd4ff78 0xde941e 0xde9253 0x1dca996 0x1dca437 0x1d2d840 0x1d2ce34 0x1d2cd4b 0x262e9dd 0x262eaa2 0xe9fa1b 0xe468 0x29d5 0x1)
terminate called throwing an exceptionwarning: Attempting to create USE_BLOCK_IN_FRAME variable with block that isn't in the frame.
When a scroll start on top of a cell, the cell is selected.
Is there a way to change this default behavior? Such that the cell is only selected when the grid is not scrolled (touch-moved), which works like the UITableView.
Any reasons this is not in ARC?
The moment the bottom of a section header view is offscreen, the whole view is kicked out.
Expected behavior: view is removed after its top is offscreen.
Currently, these two classes have the exact same interface an implementation. Steps:
Thoughts?
I think we could do this with an @synchronized
getter active-indexpath ivar that returns the appropriate _visibleCell
in -dequeueReusableCellWithIdentifier:
.
UITableView
behaviori think we can hold a vector of the stickpoints and stuff - we should get rid of the requirement to have a KKGridViewHeader returned.
I can't add a dealloc method because of ARC, and thus can't call dispatch_release(). Help?
Is it possible to add a horizontal mode as well (left-to-right / right-to-left)? I can imagine some cases in which this would be really useful if it had a vertical and horizontal mode..
I wanted to add the following macro:
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 50000
#define __kk_weak weak
#else
#define __kk_weak unsafe_unretained
#endif
to use zeroing weak references when deployment target is set >= iOS 5.0.
Apparently this doesn't work, __IPHONE_OS_VERSION_MIN_REQUIRED is always 40000 for me, even if I set deployment target to 5.0. Anyone has a better idea on how to solve this (or why this isn't working)?
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.