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

Custom UIView instead of image? #184

Open
vburojevic opened this issue Dec 5, 2012 · 8 comments
Open

Custom UIView instead of image? #184

vburojevic opened this issue Dec 5, 2012 · 8 comments

Comments

@vburojevic
Copy link

Is it possible to load custom UIView in cells?
In my example, thumbnail with controls to download and share image at the bottom of the image.

I've been trying for 2 days but haven't succeeded...

@evadne
Copy link
Collaborator

evadne commented Dec 5, 2012

Yeah, this is doable by having custom cells. Post code if you get stuck.

On Dec 5, 2012, at 10:25, "Vedran Burojević" [email protected]
wrote:

Is it possible to load custom UIView in cells?
In my example, thumbnail with controls to download and share image at the
bottom of the image.

I've been trying for 2 days but haven't succeeded...


Reply to this email directly or view it on
GitHubhttps://github.com//issues/184.

@iprebeg
Copy link

iprebeg commented Dec 5, 2012

Your custom view must inherit AQGridViewCell, that's all. Be careful, cells are cached and reused so do not rely on keeping any context inside as is will get wiped of by simple scroll on grid view. I'm talking about possible progress views and stuff.

@vburojevic
Copy link
Author

Ok, I will try, thank you.

Another questions since I posted this one already.
I am trying to set AQGridView to show 2 items in row if iPad and 1 item if iPhone.
And I want these two items (or one) to take 80 width of the screen.

I have overridden:

  • (NSUInteger) numberOfItemsPerRow
    {
    /*
    if ( _layoutDirection == AQGridViewLayoutDirectionVertical )
    return ( (NSUInteger)floorf(_boundsSize.width / _actualCellSize.width) );

    // work out how many rows we can fit
    NSUInteger rows = (NSUInteger)floorf(_boundsSize.height / _actualCellSize.height);
    if (0 == rows) {
    rows = 1;
    }
    NSUInteger cols = _numberOfItems / rows;
    if ( _numberOfItems % rows != 0 )
    cols++;
    */

    return 2; //Testing for iPad
    }

and it does show 2 in one row, but lot of space is blank on the right side.
Screenshot: http://cl.ly/image/1g310C3Q170U

What should I do so these two items fill the screen?

@iprebeg
Copy link

iprebeg commented Dec 5, 2012

Create larger cells, aqgridview will adapt to changes. You can also set content insets as desired.

Ivor Prebeg

On Dec 5, 2012, at 7:45 PM, Vedran Burojević [email protected] wrote:

Ok, I will try, thank you.

Another questions since I posted this one already.
I am trying to set AQGridView to show 2 items in row if iPad and 1 item if iPhone.
And I want these two items (or one) to take 80 width of the screen.

I have overridden:

(NSUInteger) numberOfItemsPerRow
{
/*
if ( _layoutDirection == AQGridViewLayoutDirectionVertical )
return ( (NSUInteger)floorf(_boundsSize.width / _actualCellSize.width) );

// work out how many rows we can fit
NSUInteger rows = (NSUInteger)floorf(_boundsSize.height / _actualCellSize.height);
if (0 == rows) {
rows = 1;
}
NSUInteger cols = _numberOfItems / rows;
if ( _numberOfItems % rows != 0 )
cols++;
*/

return 2; //Testing for iPad
}

and it does show 2 in one row, but lot of space is blank on the right side.
Screenshot: http://cl.ly/image/1g310C3Q170U

What should I do so these two items fill the screen?


Reply to this email directly or view it on GitHub.

@evadne
Copy link
Collaborator

evadne commented Dec 5, 2012

The better approach might be emitting different sizes in the portrait size
callback instead of overriding the grid view, then calling reload on
rotation in the animation block.

On Dec 5, 2012, at 10:45, "Vedran Burojević" [email protected]
wrote:

Ok, I will try, thank you.

Another questions since I posted this one already.
I am trying to set AQGridView to show 2 items in row if iPad and 1 item if
iPhone.
And I want these two items (or one) to take 80 width of the screen.

I have overridden:

(NSUInteger) numberOfItemsPerRow
{
/*
if ( _layoutDirection == AQGridViewLayoutDirectionVertical )
return ( (NSUInteger)floorf(_boundsSize.width / _actualCellSize.width) );

// work out how many rows we can fit
NSUInteger rows = (NSUInteger)floorf(_boundsSize.height /
_actualCellSize.height);
if (0 == rows) {
rows = 1;
}
NSUInteger cols = _numberOfItems / rows;
if ( _numberOfItems % rows != 0 )
cols++;
*/

return 2; //Testing for iPad
}

and it does show 2 in one row, but lot of space is blank on the right side.
Screenshot: http://cl.ly/image/1g310C3Q170U

What should I do so these two items fill the screen?


Reply to this email directly or view it on
GitHubhttps://github.com//issues/184#issuecomment-11054554.

@vburojevic
Copy link
Author

I tried modifying setDesiredCellSize to make cells bigger but nothing happens. Can you point me where should I edit the code to make cells brigger?

It's difficult without doumentation? There is no documentation for AQGridView right? I tried to find it but failed.

@iprebeg
Copy link

iprebeg commented Dec 5, 2012

not sure how does your code look like, but returning cell with larger frame on cellForItemAtIndex callback should do it.

Ivor Prebeg

On Dec 5, 2012, at 7:53 PM, Vedran Burojević [email protected] wrote:

I tried calling modifying setDesiredCellSize to make cells bigger but nothing happens. Can you point me where should I edit the code to make cells brigger?

It's difficult without doumentation? There is no documentation for AQGridView right? I tried to find it but failed.


Reply to this email directly or view it on GitHub.

@vburojevic
Copy link
Author

I tried:
plainCell = [[ImageDemoGridViewCell alloc] initWithFrame: CGRectMake(0.0, 0.0, 400.0, 300.0) //Doubled the values
reuseIdentifier: PlainCellIdentifier];

but I get an empty view

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

No branches or pull requests

3 participants