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

  • SEARCH
  • Home
  • 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 8880815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:13:45+00:00 2026-06-14T20:13:45+00:00

There are some discussions on how to add a UIButton to a UITableCellView in

  • 0

There are some discussions on how to add a UIButton to a UITableCellView in the famous

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

method and on how to handle button clicks. I have tested them and they all more or less work fine.

I have slightly different setup. I want to add the UIButton – in fact I have several buttons positioned on different UIImageViews – hided/shown using swipe touches, within my custom UITableCellView class. To keep things simple, let’s assume there is only one UIImageView added to the cell’s view stack and one UIButton only:

This is the relevant part of my UITableViewCell implementation:

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
   self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
   if (self) {
     // sub menu
     self.tableCellSubMenu = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320.0, 88.0)];
     [self.tableCellSubMenu setImage:[UIImage imageNamed:@"cell_menu_back"]];
     [self addSubview:self.tableCellSubMenu];

     UIButton *but = [UIButton buttonWithType:UIButtonTypeCustom];                              
     but.frame = CGRectMake(10.0, 0, 77.0, 88.0);
     [but setImage:[UIImage imageNamed:@"cell_menu_icon_plus_up"] forState:UIControlStateNormal];
     [but setImage:[UIImage imageNamed:@"cell_menu_icon_plus_down"] forState:UIControlStateSelected];
     [but setImage:[UIImage imageNamed:@"cell_menu_icon_plus_down"] forState:UIControlStateHighlighted];
     [but addTarget:self action:@selector(tableCellButtonPress:) forControlEvents:UIControlEventTouchUpInside];
     [self.tableCellSubMenu addSubview:but];
     ...
     }
   return self;
}

The UIButton is added to an UIImageView, which in turn as added to the cell’s view stack. For simplicity, I configured the target for the button to “self”. In my real setup, the target is the UITableViewController where I handle the button events. I can guarantee that all the setup is working (e.g. by replacing UIImageView with UIControl, as we see later).

Unfortunately, in this configuration, a touch up inside event on the button doesn’t fire. The only function which gets called is

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

in the controller. Usually, I place UIButtons on a UIControl view. Having said that, when I replace UIImageView with UIControl in the above code, the button event fires as expected, but then,

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

doesn’t get called anymore. I want both.

How to get this to work?

Update 1:

I have implemented the following method in my custom UITableViewCell implementation:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    CGPoint location = [((UITouch *)[touches anyObject]) locationInView:self];
    if (CGRectContainsPoint(but.frame, location)) {
      [self.touchButtonDelegate tableViewCellButtonTouched:self button:(UIButton*)but indexPath:self.touchButtonIndexPath];
    }
    [super touchesBegan:touches withEvent:event];
}

I am still using “UIImageView” to group and position several buttons.

The self.touchButtonDelegate is the UITableViewController. A more complete solution is available 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-06-14T20:13:46+00:00Added an answer on June 14, 2026 at 8:13 pm

    UIImageViews don’t have user interaction enabled. You should be adding it to the cell itself, or another UIView.

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

Sidebar

Related Questions

There has been a lot of discussions on View-engines for ASP.NET MVC and some
There's been a discussion between me and some colleagues that are taking the same
There are some posts discussing adding data-binding ability for ListView.SelectedItems with non-trivial amount of
Are there some good resources tutorials or anyone has tried to implement a Capcha
Is there some way to define an abstract type as a parameter in an
Is there some kind of software that I can feed uploaded images to and
Is there some crucial difference in writing the registry class in MVC with magic
Is there some way to use Tuning Advisor for SQL Express? Is there some
Is there some event I can use to tell when the SelectedIndices property changes
Is there some regex that can be passed to re-seq such that it will

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.