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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:06:27+00:00 2026-05-28T01:06:27+00:00

I have two UIButtons I am creating programmatically and setting targets. If I add

  • 0

I have two UIButtons I am creating programmatically and setting targets. If I add these buttons to a main view, everything works beautifully. However when I add the to a subview first and add this subview to the main view, touch events don’t work. I’m guessing these buttons are being covered up.

How can I uncover these buttons while keeping them inside the subview?

Here is my code:

// Create button panel here
UIImage *buttonPanel = [UIImage imageNamed:@"left_button_background"];
UIImageView *buttonPanelView = [[UIImageView alloc] initWithImage:buttonPanel];
[buttonPanelView setFrame:CGRectMake(20, 186, 363, 345)];

// Populate the panel with buttons
UIButton *cmsButton = [[UIButton alloc] initWithFrame:CGRectMake(10, 10, 351, 142)];
[cmsButton setImage:[UIImage imageNamed:@"BTN_MATLIB"] forState:UIControlStateNormal];
[cmsButton addTarget:self action:@selector(loadCMS) forControlEvents:UIControlEventTouchDown];
[buttonPanelView addSubview:cmsButton];
[self setCms:cmsButton];

UIButton *calcButton = [[UIButton alloc] initWithFrame:CGRectMake(10, 196, 351, 142)];
[calcButton setImage:[UIImage imageNamed:@"BTN_MORE_RESOURCES"] forState:UIControlStateNormal];
[calcButton addTarget:self action:@selector(loadCalc) forControlEvents:UIControlEventTouchDown];
[buttonPanelView addSubview:calcButton];
[self setCalc:calc];

[[self view] addSubview:buttonPanelView];
  • 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-28T01:06:27+00:00Added an answer on May 28, 2026 at 1:06 am

    Image views do not have user interactions enabled by default, which means none of their subviews can receive user interactions either.

    buttonPanelView.userInteractionEnabled = YES;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a main view screen with navcontroller in my app with two UIbuttons.
Does these two snippets accomplish the same thing? Assuming I have three IBOutlet UIButtons
I have a table view and I'm toggling its dataDource with two UIButtons (like
i have created two UIButtons and only play button is appearing on the UIToolbar.
I have two UIbuttons,and I want to implement Longpressgesture on both. So I wrote
I have two UIView's. I have an UIButton on the first view that shows
I have two buttons inside sectioned tableview cell thumbs up and thumbs down. Initially
I have two buttons inside sectioned tableview cell thumbs up and thumbs down. Initially
Hello guys i have cells in tableview, but there are two different UIButtons to
Suppose I have two buttons that are ivar outlets. One is called Blue 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.