Iphone UIImage查看uibutton中的图片标题

Iphone UIImage查看uibutton中的图片标题,iphone,ios,uiimageview,uibutton,Iphone,Ios,Uiimageview,Uibutton,在我的应用程序中,我有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

在我的应用程序中,我有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];

        }
    }
}

}
-(iAction)应答设置:(id)发送方
{
UIButton*mybutton=(UIButton*)发送方;
静态int j=0;
如果(发送方==mybutton)
j++;
如果(j>=arcount)
{
j=0;
}
else如果(j<0)
{
j=弧计数-1;
}
animage.image=[arimage objectAtIndex:j];
for(UIView*self.view.subview中的视图)
{
if([view IsKindof类:[UIButton类]])
{
UIButton*按钮=(UIButton*)视图;
如果(button.tag==1 | | | button.tag==2 | | | button.tag==3 | | button.tag==4)
{
int value=rand()%([artext count]-1);
NSMutableDictionary*dictionary=[[NSMutableDictionary alloc]init];
[字典设置值:@“imageName”forKey:@“button”];
[按钮设置标题:[artext objectAtIndex:value]用于状态:UIControlStateNormal];
}
}
}
}
而不是:

[button setTitle:[artext objectAtIndex:value] forState:UIControlStateNormal];
试试这个:

[button setTitle:[NSString stringWithFormat:@"%@",[artext objectAtIndex:value]] forState:UIControlStateNormal];

还要确保
[artext objectAtIndex:value]
确实包含一些值。

UIButton*mybutton=(UIButton*)sender。。if(sender==mybutton)我认为这个if语句是无用的。@KevinCao我用它在屏幕上显示下一张图片click@fasilmoham:你能让你的问题更清楚吗?在我看来,我有1个图像视图和4个按钮,我在图像视图中显示了一个数组中的图像,因为我想将1个按钮标题显示为当前图像名称,剩余按钮作为数组中的不同名称。我无法在按钮标题中显示图像当前图像名称,你能帮我解决吗@VenkatManohar@fasilmoham:按钮标题应该是什么..好像你正在将图像名称保存到其他地方?太好了,它正在工作问题是它是这样来的
,我如何才能得到确切的单词