Im having four buttons in my application,im getting the button title from array ,I want to change the 4 button titles whenever i click any of the button,But here the clicked button title only changed ,here my code,
-(IBAction)setting:(id)sender
{
int value = rand() % ([arraytext count] -1) ;
UIButton *mybuton = (UIButton *)sender;
[mybuton setTitle:[arraytext objectAtIndex:value] forState:UIControlStateNormal];
}
Updated
-(IBAction)answersetting:(id)sender
{
UIButton *mybutton = (UIButton *)sender;
static int j = 0;
if(sender == mybutton)
j++;
if (j >= arcount)
{
j = 0;
}
else if(j < 0)
{
j = arcount - 1;
}
CATransition *transition = [CATransition animation];
transition.duration = 1.0f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
transition.type = kCATruncationMiddle;
[animage.layer addAnimation:transition forKey:nil];
animage.image=[arimage objectAtIndex:j];
for(UIView *view in self.view.subviews)
{
if([view isKindOfClass:[UIButton class]])
{
UIButton *button = (UIButton *)view;
if(button.tag == 1||button.tag == 2||button.tag == 3||button.tag == 4)
{
int value = rand() % ([artext count] -1) ;
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc]init];
[dictionary setValue:animage.image forKey:@"button"];
[button setTitle:[artext objectAtIndex:value] forState:UIControlStateNormal];
}
}
}
}
I connect this method with 4 buttons,i want to change all button title whenever i click any of the buttons,please help to code