Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Horizontal direction seems not to work #2

Open
rs opened this issue Jun 3, 2010 · 9 comments
Open

Horizontal direction seems not to work #2

rs opened this issue Jun 3, 2010 · 9 comments

Comments

@rs
Copy link

rs commented Jun 3, 2010

In the ImageDemo example, if you put the following line in the viewDidLoad method of the ImageDemoViewController:

self.gridView.layoutDirection = AQGridViewLayoutDirectionHorizontal;

you get the following error (backtrace here: https://gist.github.com/b87ae0e00ed585cc5fd2):

2010-06-04 00:17:46.198 ImageDemo[25683:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: (range.location >= 0) && (range.location + range.length <= [_visibleCells count])'

Additionally, if you reduce the height of the GridView to lets say 200px, you get an EXC_ARITHMETIC error (backtrace here: https://gist.github.com/15ffe23f2d2af3ff3921)

@AlanQuatermain
Copy link
Owner

Yeah, it's an artifact of how it handles indexing— it counts along each row. For horizontal scrolling I'm not entirely certain what the ideal format would be. Keeping the same thing might not be the best thing, and it would definitely require a change to the way I'm tracking which items are visible (I wouldn't be able to use a range any more, I'd have to use an NSIndexSet).

In Kobo we're only using this mode with a single row (in the 'I'm Reading' expose-style overlay), so we don't hit this problem. The ImageDemo I modified here to show off horizontal scrolling does though, which is somewhat annoying. I've just not gotten around to making a decision yet how it ought to be done, or whether there should be a developer setting for it.

@darknoon
Copy link

darknoon commented Aug 5, 2010

Hey, I'd really like to see the horizontal scrolling work. Is this something that you're going to be putting time into?

I might be able to help implement it, but I think I would need to understand the code base a little deeper. I implemented a general solution to this problem that looked somewhat different (arbitrary rects and visibility testing, different layout manager for vert / horiz), but unfortunately it's owned by eBay :(

@syedhassan4
Copy link

I am also trying to implement horizontal scrolling in SINGLE row. But when I run application gives me Vertical scrolling as well, which I don't need. I only required horizontal scrolling in the gridview. Horizontal scrolling working fine, I just need to fix vertical scrolling.

Here is my UI setup and code,

  1. MyCustom view in which I place AQGridView. My Custom view height is 110px as well AQGridView height is 110px.
  2. For AQGridViewCell, I took some different approach (since I more in favour of IB). So I created a view 110x110 (width x height) and add it in gridview's as subview in contentview:

//In MyCustomView.m
-(void)awakeFromNib {
//self.gridView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
self.gridView.autoresizesSubviews = NO; //Also tried with YES
self.gridView.delegate = self;
self.gridView.dataSource = self;

self.gridView.layoutDirection = AQGridViewLayoutDirectionHorizontal;
self.gridView.separatorStyle = AQGridViewCellSeparatorStyleEmptySpace;
self.gridView.resizesCellWidthToFit = NO;
self.gridView.separatorColor = nil;

}

  • (AQGridViewCell_)gridView:(AQGridView_)aGridView cellForItemAtIndex:(NSUInteger)index {

    AQGridViewCell * cell = [aGridView dequeueReusableCellWithIdentifier:[GridItemView gridItemViewIdentifier]];
    if(cell == nil) {
    cell = [[[AQGridViewCell alloc] initWithFrame: CGRectMake(0.0, 0.0, 110.0, 110.0)
    reuseIdentifier:[GridItemView gridItemViewIdentifier]] autorelease];
    [cell.contentView addSubview:[GridItemView createGridItemview]];

    cell.contentView.backgroundColor = [UIColor clearColor];
    cell.backgroundColor = [UIColor clearColor];
    cell.contentView.opaque = NO;
    cell.opaque = NO;
    
    cell.selectionGlowColor = [UIColor blueColor];
    

    }
    //....
    return cell;
    }

  • (CGSize)portraitGridCellSizeForGridView:(AQGridView*)aGridView {
    return CGSizeMake(110.0, 110.0);
    }

//In GridItemView.m
+(id)createGridItemview {
return [[[NSBundle mainBundle] loadNibNamed:@"GridItemView" owner:self options:nil] lastObject];
}

@syedhassan4
Copy link

I think I found the issue.

Issue is in the (void) setContentSize: (CGSize) newSize function. There is a line
newSize.height = fmax(newSize.height, self.frame.size.height+1); which is creating issue so I changed it with following code. Please let me know, you see any issue in the updated code.

if(self.layoutDirection == AQGridViewLayoutDirectionHorizontal)
    newSize.height = fmax(newSize.height, self.frame.size.height);
else
    newSize.height = fmax(newSize.height, self.frame.size.height+1);

It fixes the vertical scrolling issue in Single Row Horizontal gridview.

@adsahay
Copy link

adsahay commented Jun 3, 2011

What's the status of this issue? Using a range to define visible cells won't work in multi-row horizontal scrolling, NSIndexPath sounds better. Is someone working on this (I am not expert enough to fix it myself)?

@coreyfloyd
Copy link

Found a branch with a partial fix. They moved to an index set.

https://github.com/marcammann/AQGridView/

So far it seems to work.

I am working on the other part, which is to re-layout the indexes into the logical pages. That is to say page 0 should contain indexes 0-19, page 1 20-29, etc…

@nbonatsakis
Copy link

Any word on how this is coming? I'd like to use this library for a single row, paged scrolling grid view. It sounds like this would be needed.

@Ricardo1980
Copy link

I think I also see that error.
"*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: range.location + range.length <= [_visibleCells count]'"

I created a grid on the iPad and I always see it when I rotate it several times.
Any suggestion or idea about how to fix this?
This is a nice lib and works ok for me except that detail.

@imrano16
Copy link

My AQGridView Horizontal scrolling is not working

and get the following error...
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* setObjectForKey: key cannot be nil'
*** First throw call stack:
(
0 CoreFoundation 0x0048c5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0382a8b6 objc_exception_throw + 44
2 CoreFoundation 0x00516578 -[__NSDictionaryM setObject:forKey:] + 888
.
.
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants