I have seen many Questions and still i didn't get exact response I need. Is it possible to change the number of segments in UISegmented control based on array count. When I tried it is showing error:"assigning to readonly property".
Asked
Active
Viewed 674 times
0
-
possible duplicate: https://stackoverflow.com/a/23179457/7084910 – Jay Patel Jul 21 '17 at 07:33
-
You need to remove all items from UISegmentedControl and insert by array elements. – Jay Patel Jul 21 '17 at 07:34
1 Answers
0
Did you try that:
- (void)setSegments:(NSArray *)segments {
[segmentController removeAllSegments];
for (NSString *segment in segments) {
[segmentController insertSegmentWithTitle:segment atIndex:segmentController.numberOfSegments animated:NO];
}
}

Floris M
- 1,764
- 19
- 18