Reputation: 426
I am not able to select the index in my UISegmentController. I can manually touch via the simulator and I can set the selectedSegmentIndex via code, but I am not able to have it show up in the simulator the index that I have set via code. What I would like to see is that the index that I have set shows as being selected to the user, without the user actually physically clicking on the item.
if([mealPlanTable isHidden]){
segCont.selectedSegmentIndex = 0;
NSLog(@"%d", [segCont selectedSegmentIndex]);
[self mainControl:segCont];
}
This will set the index and then call the mainController which does an action based on the index selected, which does work. I am able to use the value that I set but am just not able to visually see that the Segment is selected aka is blue in the simulator.
Upvotes: 0
Views: 182
Reputation: 4607
How is the segmented control added to the view? If it is via interface builder, make sure you linked it as an IBOutlet and use it's property for access ie self.segmentedControl. If you added it directly, again, make sure you are using the proper instance variable. Also make sure you are calling it from the proper place in view loading.
Upvotes: 2
Reputation: 8720
Where are you calling this? If it's in init, try placing it in the viewDidLoad or viewWillAppear method.
Upvotes: 2