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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:27:52+00:00 2026-06-01T20:27:52+00:00

I’m having some trouble getting my buttons to work below a certain y value

  • 0

I’m having some trouble getting my buttons to work below a certain y value in my table cells. I’m using a custom UITableViewCell class named “RowWhiskyContent”. The default height is 44px and it’s below that point my events don’t seem to trigger anymore. The button displays just fine and so does everything else below that point, the event however don’t seem to trigger. If i place my button half way (like at y=35) only the top part of the button triggers the event and the bottom part doesn’t do a thing.

Here’s the code trimmed down to the esentials:

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell  *cell = nil;

    if(![self createView:&cell])
    {
        UIImage *bottle = [UIImage imageNamed:@"icon_add.png"]; //image size: 22x22
        UIButton *bottleButton = [[UIButton alloc] initWithFrame:CGRectMake(60, 70, bottle.size.width, bottle.size.height)]; 

        [bottleButton setImage:bottle forState:UIControlStateNormal];
        [cell.contentView addSubview:bottleButton];
        [bottleButton addTarget:self action:@selector(addToCollection:) forControlEvents:UIControlEventTouchUpInside];

        cell.contentView.frame = CGRectMake(cell.contentView.frame.origin.x, cell.contentView.frame.origin.y, cell.contentView.frame.size.width, 160);
        //cell.frame = cell.contentView.frame; // Tried this, didn't work.
        //[tableView reloadData]; // Tried this too, didn't work either.
    }
    return cell;
}

// Check if cell exists and create the cell if it doesn't.
-(BOOL) createView: (UITableViewCell**) cell
{
    BOOL cellExists = YES;
    *cell = (RowWhiskyContent *) [myTableView dequeueReusableCellWithIdentifier:@"ContentIdentifier"];    
    if(*cell == nil)
    {
        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"RowWhiskyContent" owner:self options:nil];
        *cell = [topLevelObjects objectAtIndex:0];
        cellExists = NO;
    }
    return cellExists;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
{
    return 160;
}

Since I’m setting the height of the cell and the contentView both at 160 I’m not sure what’s going wrong here. Reloading the data didn’t work and neither did setting the cell.frame.

Could anybody please tell me what I’m doing wrong?
Thanks in advance.

EDIT:
Added a screenshot:

enter image description here

Red button works fine but if I place it at the position of the green button it stops working. The contentview’s background is set to purple so that explains the purple area. When clicking the cell it triggers the didSelectRowAtIndexPath so I’m guessing the the cell itself is also big enough.

  • 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-01T20:27:53+00:00Added an answer on June 1, 2026 at 8:27 pm

    This is definitely a content size issue. Your button will display outside of the frame similar to overflow in CSS, however they will not respond to events. So whatever UIView is containing your UIButton you need to make sure that it’s content/frame/bounds are all set tall enough. You can also use [cell.contentView sizeToFit] to adjust it automatically to it’s content.

    You should definitely NOT reload data inside of the protocol methods for your UITableView.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.