I need to read from an XML document which is alreay working. But now I have to write UISegmentedcontrols with the values out of that XML. The values that are parsed are in this format:
<wcqAnswerValues>slecht;matig;voldoende;goed</wcqAnswerValues>
Which are four values, separated by the semicolon. So the UISegmentedControl needs to get four segments. The first two segments need to have actions on them. How do I split those four values and put them into an UISegmentedControl?
If the first two values are selected, a textfield needs to pop out. How can I do this?
static CGFloat y1 = 100.0f;
do {
if ([[TBXML elementName:element] isEqualToString:@"wcqAnswerValues"]) {
UISegmentedControl *answer = [[UISegmentedControl alloc] initWithFrame:CGRectMake(50, y1, 250, 50)];
answer.segmentedControlStyle = UISegmentedControlStyleBar;
[scrollView addSubview:answer];
[formulierText removeFromSuperview];
[answer release];
y1 += 50.0f;
}
Use componentsSeperatedByString: method to split a string into an array. And use addTarget:action:forControlEvents: method to handle segment selection action.
The someMethod: method looks like this.