How to automatically stretch UISegmented Control horizontally to populate a full UITableViewCell? Thus, it will automatically resize after changing orientation.
I tried the following, however this still does not work. The segmented control appears in the cell on the left, but does not stretch horizontally.
NSArray *itemArray = [NSArray arrayWithObjects: @"Feet", @"Metric", nil];
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:itemArray];
segmentedControl.selectedSegmentIndex = [self.config.isMetric boolValue] ? 1 : 0;
segmentedControl.contentMode = UIViewContentModeScaleToFill;
[cell.contentView addSubview:segmentedControl];
cell.contentView.contentMode = UIViewContentModeScaleToFill;
[segmentedControl release];
source
share