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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:38:27+00:00 2026-06-11T18:38:27+00:00

I have a subview which is allmost half to my mainview and also I

  • 0

I have a subview which is allmost half to my mainview and also I have a UISlider on my mainview . My silder has a value from 0 to 10. i want to add some UIButtons to my Subview with the UISilder.Now if my silder get the value 2 then i want to add 2 UIButtons to my Subview as if my silder pass the value 2 and gets the value 4 then I want to remove the previous UIButtons from Subview and Add some new UIButtons to 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-06-11T18:38:28+00:00Added an answer on June 11, 2026 at 6:38 pm

    Note: The code is untested.

    1. Initiate a 10 UIButton and add them to the view, set them as hidden:

      for (int x = 0; x < 10; x++) {
          UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(50, x * 100, 100, 50)];
          [btn setText:[NSString stringWithFormat:@"Button %d",(x + 1)]];
          [btn setHidden:true];
          [self.view addObject:btn];
          [btn release];
      }
      
    2. Use the slider change value method to hide/show the buttons like this:

          -(IBAction) sliderChanged:(id) sender{
                UISlider *slider = (UISlider *) sender;
                for (int x = 0; x < slider.value; x++) {
                     UIButton *btn = (UIButton *)[savedBtn objectAtIndex:x];
                     [btn setHidden:false];
                }
          }
      

    Update

    To use a UIScrollView, you have to add the UIButtons to the scrollView instead of the view, like this:

        UIScrollView *sView = [[UIScrollView alloc] initWithFrame:CGRectMake(10,10,200,200)];
        [sView setDelegate:self];
        for (int x = 0; x < 10; x++) {
            UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(50, x * 100, 100, 50)];
            [btn setText:[NSString stringWithFormat:@"Button %d",(x + 1)]];
            [btn setHidden:true];
            [sView addSubview:btn];
            [btn release];
        }
    

    then add the scrollView to the view:

         [self.view addSubview:sView];
    

    hope this can help you.

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

Sidebar

Related Questions

I have this subview I want to add to my main view, but make
I have a scrollView with a UIView as subview, which in turn has many
In my app i have an UISlider which is subview of UIScrollView , where
I have a UITapGestureRecognizer which basically performs an action to add a subview. When
I have a CALayer which I merely create and add to a subview of
I have a UIPickerView as subview in a UITableViewController, which I want to slide
I have two ImageViews, one called imageView and the other called subView (which is
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 main view to which I have added a subview using the

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.