Reputation: 67
i have the following 6 segments in my UISegmentedControl
1)Objective 2)Concept 3)How-to-Do 4)Note 5)Simulation 6)CYU
when i launch my app i get to see only 3 segments while the other 3 remain hidden due to the simulators frame,how can i display all the 6 segments? how to toggle across the other segments? sorry for the noob question,i couldnt find any solution to this anywhere
Upvotes: 0
Views: 1396
Reputation: 38249
One alternative is
UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 60)];
scroll.showsHorizontalScrollIndicator = NO; //disable horizontal scroll
scroll.showsVerticalScrollIndicator = NO; //disable vertical scroll
NSArray *itemArray = [NSArray arrayWithObjects: @"Objective", @"Concept", @"How-to-Do",@"Note",@"Simulation",@"CYU", nil];
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:itemArray]; //provide array of segment names
segmentedControl.frame = CGRectMake(0, 0, 600, 50);//change accordingly
segmentedControl.segmentedControlStyle = UISegmentedControlStylePlain;
segmentedControl.selectedSegmentIndex = 1; //by default selected index
[scroll addSubview:segmentedControl]; // add segment
scroll.contentSize = CGSizeMake(segmentedControl.frame.size.width, segmentedControl.frame.size.height+10); //change accordingly
[segmentedControl release];
[self.view addSubview:scroll]; //add scroll view
Upvotes: 2