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.
source share