Reputation: 277
The segment control is cant able to relocate the position in vertical.It shows like in the image .Can any one help me to positioning the segment control.
int offset = BAR_OFFSET + 40 * bars.count;
for (int i = bars.count; i < guessRows; i++)
{
UISegmentedControl *bar = [[UISegmentedControl alloc] initWithItems:
[NSArray arrayWithObjects:@"", @"", @"", nil]];
bar.segmentedControlStyle = UISegmentedControlStyleBar;
bar.transform = CGAffineTransformMakeRotation(M_PI_2);
bar.momentary = YES;
[bar addTarget:self action:@selector(submitGuess:)
forControlEvents:UIControlEventValueChanged];
CGRect frame = bar.frame;
frame.origin.y = offset; // position it below the last bar
frame.origin.x = 20; // give it some padding on the left
[self.view addSubview:bar]; // add the bar to the main view
[bars addObject:bar];
[bar release];
}
Upvotes: 1
Views: 1893
Reputation: 49730
you can create segment control programmatic and set frame to maintain your segment control position and add segmentcontrol to your view Controller like this :-
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:itemArray];
segmentedControl.frame = CGRectMake(35, 200, 250, 50);
segmentedControl.segmentedControlStyle = UISegmentedControlStylePlain;
segmentedControl.selectedSegmentIndex = 1;
[self.view addSubview:segmentedControl];
Upvotes: 2
Reputation: 7410
The problem comes from your offset
var. At line :
frame.origin.y = offset; // position it below the last bar
Change its value (increase it to lower the position of the view) and try to find the correct value that displays your control correctly.
Upvotes: 1