Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is the top portion of my UISegmentedControl not tappable?
    primarykey
    data
    text
    <p>While I was playing on my phone, I noticed that my UISegmentedControl was not very responsive. It would take 2 or more tries to make my taps register. So I decided to run my app in Simulator to more precisely probe what was wrong. By clicking dozens of times with my mouse, I determined that the top 25% of the UISegmentedControl does not respond (the portion is highlighted in red with Photoshop in the screenshot below). I am not aware of any invisible UIView that could be blocking it. Do you know how to make the entire control tappable?</p> <p><img src="https://i.stack.imgur.com/06bkB.png" alt="uinavigationbar uisegmentedcontrol"></p> <pre><code>self.segmentedControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Uno", @"Dos", nil]]; self.segmentedControl.selectedSegmentIndex = 0; [self.segmentedControl addTarget:self action:@selector(segmentedControlChanged:) forControlEvents:UIControlEventValueChanged]; self.segmentedControl.height = 32.0; self.segmentedControl.width = 310.0; self.segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar; self.segmentedControl.tintColor = [UIColor colorWithWhite:0.9 alpha:1.0]; self.segmentedControl.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; UIView* toolbar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, HEADER_HEIGHT)]; toolbar.autoresizingMask = UIViewAutoresizingFlexibleWidth; CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.frame = CGRectMake( toolbar.bounds.origin.x, toolbar.bounds.origin.y, // * 2 for enough slack when iPad rotates toolbar.bounds.size.width * 2, toolbar.bounds.size.height ); gradient.colors = [NSArray arrayWithObjects: (id)[[UIColor whiteColor] CGColor], (id)[[UIColor colorWithWhite:0.8 alpha:1.0 ] CGColor ], nil ]; [toolbar.layer insertSublayer:gradient atIndex:0]; toolbar.backgroundColor = [UIColor navigationBarShadowColor]; [toolbar addSubview:self.segmentedControl]; UIView* border = [[UIView alloc] initWithFrame:CGRectMake(0, HEADER_HEIGHT - 1, toolbar.width, 1)]; border.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin; border.backgroundColor = [UIColor colorWithWhite:0.7 alpha:1.0]; border.autoresizingMask = UIViewAutoresizingFlexibleWidth; [toolbar addSubview:border]; [self.segmentedControl centerInParent]; self.tableView.tableHeaderView = toolbar; </code></pre> <p><p><a href="http://beta.vidopop.com/v/bqung5">http://scs.veetle.com/soget/session-thumbnails/5363e222d2e10/86a8dd984fcaddee339dd881544ecac7/5363e222d2e10_86a8dd984fcaddee339dd881544ecac7_20140509171623_536d6fd78f503_68_896x672.jpg</a></p></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload