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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:49:36+00:00 2026-05-26T18:49:36+00:00

I have a uisegmentedcontrol within a horizontally scrolling uiscrollview. The scrollview is working just

  • 0

I have a uisegmentedcontrol within a horizontally scrolling uiscrollview. The scrollview is working just fine and the content is resized according to the width of the segmentedcontrol. The segmented control detects the touches on those segments that are visible when first displayed. If I scroll to the right I am unable to select the newly displayed segments. The cuttof is not exactly a segment either, its what was initially displayed, like if there was a view clipping it. thanks for the help, i have deselected clip subviews from the scrollview.

// creates segmented control to indicate test to show on graph

    UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:self.labels];
    segmentedControl.frame = CGRectMake(15, 41, 285, 30);
    segmentedControl.autoresizingMask = 
    segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
    segmentedControl.selectedSegmentIndex = 0;
    segmentedControl.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    [segmentedControl addTarget:self action:@selector(testChange:) forControlEvents:UIControlEventValueChanged];

    //checks the length of the text in each segment and asjusts control accordingly
    int x = 0;
    segmentWidth = 0.0;
    for (id segment in [segmentedControl subviews]) 
    {
        for (id label in [segment subviews]) 
        {
            if ([label isKindOfClass:[UILabel class]])
            {

                [label setTextAlignment:UITextAlignmentCenter];
                [label setFont:[UIFont boldSystemFontOfSize:12]];

                CGFloat textWidth = [[segmentedControl titleForSegmentAtIndex:x] sizeWithFont:[UIFont boldSystemFontOfSize:12.0]].width + 20;
                [segmentedControl setWidth:textWidth forSegmentAtIndex:x];
                segmentWidth += textWidth;
            }
        }
        x++;
    }

    self.testSegment = segmentedControl;
    [segmentedControl release];

    //adds segmentedcontroll to scrollview, and adjusts contensize
    [scrollView setContentSize:CGSizeMake(segmentWidth + 45, scrollView.frame.size.height)];
    [scrollView showsHorizontalScrollIndicator];
    [scrollView addSubview:testSegment];
  • 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-26T18:49:36+00:00Added an answer on May 26, 2026 at 6:49 pm

    fixed, problem is that I had set the frame of the segmented control before calculating the widths of each segment.

    segmentedControl.frame = CGRectMake(15, 41, segmentWidth+20, 30);
    

    before

    self.testSegment = segmentedControl;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UISegmentedControl within a view both within a xib. In my app
So, I have a UISegmentedControl with: [control addTarget:self action:@selector(myAction) forControlEvents:UIControlEventValueChanged]; Just wondering how I
I have a UISegmentedControl on a black UIToolbar. I have set the style to
I have a checklist in a UITableView and I have a UISegmentedControl with Select
Have just started using Google Chrome , and noticed in parts of our site,
Have just started using Visual Studio Professional's built-in unit testing features, which as I
I have a UISegmentedControl containing 3 options for selecting map type. I am setting
I currently have a UISegmentedControl set to add/remove table view cells when its value
I was wondering what the best approach in order to have a UISegmentedControl appears
I am new to iPhone development. I have created UISegmentedControl having 2 segments. I

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.