IPhone - adding UISegmentedControl to the control panel of the navigation controller

Is this heresy to add a UISegmentedControl to the Controller's control panel?

I am reviewing this code:

UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems: [NSArray arrayWithObjects: [NSString stringWithString:NSLocalizedString(@"One", @"")], [NSString stringWithString:NSLocalizedString(@"Two", @"")], [NSString stringWithString:NSLocalizedString(@"Three", @"")], [NSString stringWithString:NSLocalizedString(@"Four", @"")], nil]]; segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar; segmentedControl.tintColor = [UIColor blackColor]; [segmentedControl setSelectedSegmentIndex:0]; [segmentedControl addTarget:self action:@selector(changeSegment:) forControlEvents:UIControlEventValueChanged]; [segmentedControl setFrame:[self.navigationController.toolbar bounds]]; [self.navigationController.toolbar addSubview:segmentedControl]; [segmentedControl release]; 

I tried this code and segments are not showing if I touch them.

Is this the right way to do this?

thanks.

+4
source share
1 answer

This is most likely due to the fact that your tintColor is black. Change the color and you will see that the selected segment is reflected.

+2
source

All Articles