Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8406463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:07:01+00:00 2026-06-09T23:07:01+00:00

As AQGridview borrows a lot of it’s ideas from UITableView so I think the

  • 0

As AQGridview borrows a lot of it’s ideas from UITableView so I think the answer should apply to both.

I have a custom cell with the following objects inside:

  • label
  • favourite button (can be turned on/off by the user and I use .selected = YES/NO)

The problem is maintain the state of the button when scrolling. Below is my ‘cellForItemAtIndex’ method.

- (AQGridViewCell *) gridView: (AQGridView *) aGridView cellForItemAtIndex: (NSUInteger) index
{
    static NSString * cellIdentifier = @"CellIdentifier";

    SampleGridViewCell * cell = (SampleGridViewCell *)[aGridView dequeueReusableCellWithIdentifier:cellIdentifier];

    if ( cell == nil )
    {
        cell = [[SampleGridViewCell alloc] initWithFrame: CGRectMake(0.0, 0.0, 200, 60)                                   reuseIdentifier: cellIdentifier];
    }

    NSDictionary *item = [self.items objectAtIndex:index];

    NSString *title = [item objectForKey:@"title"];

    cell.index = index;

    cell.titleLabel.text = title;

    //cell.favButton.selected = (logic goes here);

    return cell;

}

Somehow I need to keep a reference in my viewcontroller of when an item has been favourited so that I can turn the button on/off when the cell is recreated in this method.

Do I do an addTarget on cell.favButton with a method in the vc? But then how do I get a reference to the index of the button?

Has someone implemented something similar?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:07:02+00:00Added an answer on June 9, 2026 at 11:07 pm

    As you said, add a target to you button to whatever method you want. In that method, you can then get the rows index by using

                  NSSet *touches = [event allTouches];
                  UITouch *touch = [touches anyObject];
    CGPoint currentTouchPosition = [touch locationInView:tableview];
          NSIndexPath *indexPath = [tableview indexPathForRowAtPoint: currentTouchPosition];
                  NSUInteger row = [indexPath row];
    

    From there you can then store that the button has been pressed in your existing data set that is being used by the table itself.
    Then when the table gets loaded, and you retrieve your data, simply enable/disabled the cells button based on the data you’ve got stored for that row 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UITableView which I am trying to sync w/ a grid (AQGridview)
I'm using AQGridView to display images from a web service. When I touch a
Anyone have a good comparison between KKGridView and AQGridView ? Is there a reason
I have an instance of AQGridView laid out in a Pages-esque manner for the
I have a UISearchBar inside of UIScrollView (well, to be precise an AQGridView). Now
The Problem: I have two View Controllers loaded into a root View Controller. Both
I have an odd problem. I am using an AQGridView which has a method
I pulled AQGridView from the latest git repos based on recommendations from here. I
I create a custom AQGridViewCell like so: - (AQGridViewCell *) gridView: (AQGridView *) aGridView
I am using AQGridView to create an image gallery that has about 21 items.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.