ios - How to enable and disable certain UISegmentedControl segments based on selection in preceding segments -
I am trying to enable / disable certain sections, depending on the selection in the first section containing the controls 2 selects different segmented controls user.
First Section: Black | Lal Green |
Second section: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13. 14 | 15 | 16 | 17 | 18 |
Third clause: | 19 | ..... | 36 | 00 |
I want the functionality to be that if the user selects black, then only a few numbers in the second and third sections should be triggered. Since the second and third sections require the initial input of the first block, I have completely disabled the Segment in VeeDidLoad Good, now it is disabled and gray (desired behavior). But when the user taps on "black", I want some number in the Finally, I do not have both fields enabled (as is ready in ViewDidLoad) and for some reason they will not be able to enable when I explicitly enable each segment I will tell separately. I can enable the full second sezing by doing only You must first enable the controls containing the segment. You can then enable or disable individual segments. Perhaps you should have the split control enabled at all times, and only different segments should be updated based on the color. [Second row set enabled: (Color index == 2) segmentoutindex: 0]; [Set the second row enabled: (color index == 1) for segmentoutindex: 1]; [Set the second line enabled: (color index == 0) for segmentoutindex: 2]; [Set second row enabled: (color index == 1) for segmentoutindex: 3]; // ... Of course it can be simplified with a loop. enabled = yes
- (zero) viewDidoadload [[Super Viewedload]; // Setup an additional after loading the view // Do not ensure what to use and why [auto. Second set set enabled: no]; //self.secondSegment.enabled = NO; [Self. Third set set enabled: no]; //self.thirdSegment.enabled = NO; }
secondSegment and
third segment properties to be able to select the user:
- (IBAction) Color changed: (ID) Sender {UISegmentedControl * secondRow = self.secondSegment; UISegmentedControl * thirdRow = self.thirdSegment; NSString * colorName; NSInteger colorIndex = [Segment indices selected to select oneself]; If (colorIndex == 0) {colorName = @ "black"; } Else if (colorIndex == 1) {colorName = @ "Red"; } Else if (colorIndex == 2) {colorName = @ "green"; } // NSLog is correct and when you choose NSLog (@ "% @", colorName) displays the correct color; // red numbers 1,3,5,7,9,12,14,16,189, 21, 23, 25, 27, 30,32,34,36 / s 0 and 00 / if they are selected " Black "I want to re-enable these areas for the other sections if (color indicator == 0) {[secured set enable: yes SEZTindex: 2]; [Set the second line enabled: Yes, SEZ and EX: 4]; [Set the second line enabled: Yes, SEZ & X: 6]; [Set the second row enabled: yesgateindex: 8]; [Set second row enabled: Yes for SEZEndex: 10]; [Set the second line enabled: yesgateindex: 11]; [Set the second line enabled: Yes, SEZAdWordsX: 13]; [Set second row enabled: Yes, SEZ and XX: 15]; [Set the second line enabled: yesGuitindex: 17]; }}
self.secondSegment.enabled = YES , but I can not understand why I can not enable specific areas for my life.
Comments
Post a Comment