在我的应用程序中,我有 1 个图像视图和 4 个按钮,我想在其中一个按钮标题中显示图像名称,其余 3 个按钮应该显示其他标题,这是我的代码,它不起作用,请帮我解决
-(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;
}
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:@"imageName" forKey:@"button"];
[button setTitle:[artext objectAtIndex:value] forState:UIControlStateNormal];
}
}
}
}