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 6654585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:24:26+00:00 2026-05-26T01:24:26+00:00

I’m trying to replace standard table cell selection behavior with a button-press behavior. The

  • 0

I’m trying to replace standard table cell selection behavior with a button-press behavior. The result should be same – to push detailViewController on top and to present some detail info. The cell view is loaded from a separate xib file. So, I need to put a button in that cell xib and use that button for opening detail VC in table VC. I have placed the button view in cell xib, and disabled cell selection in table VC viewDidLoad, but now, I’m not sure how to handle that button press, where to place the button press code or what delegate method to use because didSelectRowAtIndexPath is not respoding (cos I disabled it). Any suggestions?

UPDATE: I need to get some info from cell (section, index) on button press in order to initialize the data for detail VC. Also, should note, that there will be several buttons in each cell.

UPDATE2: I’m using rows with sections, so on button press I need to pass both section and row numbers that corresponds to cell where the button was pressed.

UPDATE3: I have tried to use unique tags for identifying cells but it looks like it’s not the solution because I’m getting problems with cell reusing. The first 9 rows are created and relevant tag number are set to them. But then every row from 10 is reused from the queue, so I get the same 9 view with their tags. For example, 10th row pops me the first row button from the queue with the tag 1, 11th – second row button with tag 2 and so on. I mean, the whole dequeue cells means that it doesn’t matter how much rows do you have in table, there will be reused 9 cell views for all of the table rows. That means I cannot assign unique tags for the cells because the cell views are not unique for each row

  • 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-05-26T01:24:26+00:00Added an answer on May 26, 2026 at 1:24 am

    The suggestions with tags didn’t worked out because of a reason described in UPDATE3. However, I did succeed by calling “magic” indexPathForRowAtPoint: method. So the solutions is:

    1) attach custom method for button press in cellForRowAtIndexPath:

    // I have already created/loaded and got a handler to my button btn 
    // here comes attaching
    [btn addTarget:self action:@selector(openDetailViewController:event:) forControlEvents:UIControlEventTouchUpInside];
    

    2) Define custom method:

    -(void)openDetailViewController:(id)sender event:(UIEvent *)event{
    
      NSSet *touches = [event allTouches];
      UITouch *touch = [touches anyObject];
      CGPoint currentTouchPosition = [touch locationInView:self.tableView];
      NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:currentTouchPosition];
      // do my stuff
    }
    

    So, when the button gets pressed my method gets called, passing some additional parameter like event. By calling “allTouches” and “anyObject” I’m getting the touch. Then, I’m retrieving CGPoint from that touch, then passing that point to “indexPathForRowAtPoint” that returns desired indexPath with section and row number. Cool 🙂

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

Sidebar

Related Questions

No related questions found

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.