I am doing an application on a Multiple Choice Question (MCQ) where I have to get questions, answers from a webservice. I have 1 question with 4 options, among the 4 options, I have 1 correct answer. Each of the options, I created a button programmatically. This is how I did it:
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(40, yButton, 30, 30);
[button setTitle:@" " forState:UIControlStateNormal];
[button addTarget:self action:@selector(correctPressed)
forControlEvents:UIControlEventTouchDown];
[buttonArray addObject:button];
How many options I have in a questions will determine how many buttons will be created. Now when I want to show an indication that when a certain button is clicked, that button needs to stay highlighted until I decides to change my answer. I have done a few approaches.
I used IndexPath, hoping I could use indexPath.row like in TableView. It didnt work out at all. Can anyone help?
Thanks
}
-(void)VideoButtonSelected:(UIButton*)sender{
NSArray *myWords = [[[videolistArray objectAtIndex:sender.tag] valueForKey:@”video”] componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@”/”]];
//NSLog(@”%@”,[myWords lastObject]);
[setAlarmVedioButton setTitle:[myWords lastObject] forState:UIControlStateNormal];
[videoNameButtonView removeFromSuperview];
vedioString=[[videolistArray objectAtIndex:sender.tag] valueForKey:@”video”] ;
}
in above code me make uibutton with help of array count and when i select any button then it display the same text value of array on last button