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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:47:34+00:00 2026-05-31T13:47:34+00:00

I have subview which it initiated by touch on the UIbutton in the main

  • 0

I have subview which it initiated by touch on the UIbutton in the main view.
Once the subview pops up it displays a label with the info I provided. This all works. I just need an UIbutton to show up so I can then set it up to dismiss the subview and go back to the main view. i have searched all over and have found nothing that helps.

Here is what my code in my .m file looks like:

////Button that Displays Subview with Its Label and Button
- (IBAction)showInfo:(id)sender
/////UI Subview

{UIView *mySubview = [[UIView alloc] initWithFrame:CGRectMake(0, 0,320, 480)];

[self.view addSubview:mySubview];
mySubview.backgroundColor = [UIColor blackColor];
mySubview.alpha = .7f;

//////Label in SubView

{UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 300, 50)];
label.text = @"Here is info";
label.textColor = [UIColor whiteColor];
label.backgroundColor= [UIColor clearColor];

[self.view addSubview:label];


////Button in Subview

//create the button
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:[UIImage imageNamed:@"button-info-x.png"]     forState:UIControlStateNormal];

//set the position of the button
button.frame = CGRectMake(120, 252, 68, 68);


//add the button to the view
[self.view addSubview:button];

Now I just need to add an action to the UIButton to dismiss the Subview?

  • 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-31T13:47:35+00:00Added an answer on May 31, 2026 at 1:47 pm

    First Take IBOutlet of subView and add it to the main View.

     IBOutlet UIView *subView;
    

    Then, add UIButton to the SubView like this:

    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    
    //set the position of the button
    button.frame = CGRectMake(0, 0, 100, 30);
    
    //set the button's title
    [button setTitle:@"Click Me!" forState:UIControlStateNormal];
    
    [btnMenu addTarget:self action:@selector(your MethodName:) forControlEvents:UIControlEventTouchUpInside];
    
    //add the button to the view
    [subView addSubview:button];
    

    Then,

    -(IBAction)your MethodName:(id)sender {
    
    
    }
    

    In Above Method Remove SubView from Main View.

    • 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 to which I have added a subview using the
I have a simple app which adds a subview over the main view when
I have a View A, which loads a subview B which loads a subview
I have a backbone view which load subview. When I load a subview, I
I have a custom NSView which contains a subview—for the purposes of solving this
I have a UINavigationController which I add a subview to. [masterNavigationController.view addSubview:footerViewController.view]; The problem
I am adding a subview (which is a class's view) to my view.i have
I have a controller view. This controller has a PDFView as a subview and
I have a view which is a part of a tabBarController. In this view
I have a view interface which contains a subview touchWheel . On clicking a

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.