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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:46:23+00:00 2026-05-23T02:46:23+00:00

I have implemented the accessory view of a UITableViewCell as a button, in the

  • 0

I have implemented the accessory view of a UITableViewCell as a button, in the
button’s selector method i have the following code

   - (UIButton *) makeDetailDisclosureButton
   {
       UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
   UIImage* image = [UIImage imageNamed:@"custom.png"];
  [button setImage:image forState:UIControlStateNormal];
  button.frame = CGRectMake(0.0, 0.0, image.size.width, image.size.height);

   [button addTarget: self
           action: @selector(accessoryButtonTapped:withEvent:)
         forControlEvents: UIControlEventTouchUpInside];

      return ( button );
    }


  - (void) accessoryButtonTapped: (UIControl *)button withEvent:(UIEvent *) event
   {
       NSSet *touches = [event allTouches];
   UITouch *touch = [touches anyObject];
   CGPoint currentTouchPosition = [touch locationInView:self.tableView];
   NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:currentTouchPosition];
   if (indexPath != nil)
   {
    [self tableView: self.tableView accessoryButtonTappedForRowWithIndexPath: indexPath];
  }
}

However sometimes the wrong row is being selected, ie if I tap on row 0 in the table i get
row = 1 actually being selected. The code above is quite well known as a solution for
a custom accessory view but it is proving unreliable. Is there something else i need to do here?

  • 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-23T02:46:24+00:00Added an answer on May 23, 2026 at 2:46 am

    Try this,

    - (void) accessoryButtonTapped: (UIControl *)button withEvent:(UIEvent *) event
    {
        UITableViewCell *cell = (UITableViewCell*)button.superview.superview;
        NSIndexPath *indexPath = [self.tableView indexPathForCell:cell]; 
        [self tableView:self.tableView accessoryButtonTappedForRowWithIndexPath:indexPath];
    }
    

    The idea here is pretty basic. Button’s superview should give me cell.contentView and it’s superview is the cell. There is lovely helper method indexPathForCell: which will give us the index path which we can use to pass to the delegate method.

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

Sidebar

Related Questions

I have installed paperclip and imagemagick,and implemented the code to my model and view
I have a problem with the UItableViewCell accessory button. My accessory button is connected
I have implemented correctly bump's api, and added this code: - (void) configureBump {
I have implemented a table view with multiple threads. Currently when a user taps
I have implemented a test method with Jersey to run on my Google AppEngine
I have implemented clean URLs using the following in my .htaccess RewriteEngine on RewriteCond
I have implemented one matrix multiplication with boost::numeric::ublas::matrix (see my full, working boost code
I have this following function implemented in my app There are no errors at
I have the following code: class Engine attr_accessor :isRunning def initialize @isRunning = false
I have implemented pagination to my data, but the problem is I only have

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.