Iphone 检索按钮标记时出现问题

Iphone 检索按钮标记时出现问题,iphone,ipad,Iphone,Ipad,我的应用程序要求如下:- 1.)根据库中存储的图像数量制作一个Button(我已经完成了)。 2.)当用户单击禁用按钮时禁用所有按钮。 为了完全满足第二个要求,我在创建按钮时设置了每个按钮的标签: button.setTag=tag; 其中,e上的标记增加1 问题是,当我禁用按钮时,它只禁用最后一个按钮。我如何才能逐个访问按钮标签值 for (int index = 0; index < [objectButtonArray count];index++) { UIButton

我的应用程序要求如下:-

1.)根据库中存储的图像数量制作一个Button(我已经完成了)。 2.)当用户单击禁用按钮时禁用所有按钮。 为了完全满足第二个要求,我在创建按钮时设置了每个按钮的标签:

button.setTag=tag;
其中,e上的标记增加1

问题是,当我禁用按钮时,它只禁用最后一个按钮。我如何才能逐个访问按钮标签值

for (int index = 0; index < [objectButtonArray count];index++) { 
    UIButton *button = [objectButtonArray objectAtIndex:index]; 
    button.hidden = NO; 
    imageButton.userInteractionEnabled = NO; 
} 
for(int index=0;index<[objectButtonArray count];index++){
UIButton*button=[objectButtonArray objectAtIndex:index];
button.hidden=否;
imageButton.userInteractionEnabled=否;
} 
试试这个方法

for (UIView *view in yourView.subviews) {

                        [view viewWithTag:BUTTON_TAG].userInteractionEnabled = NO;
                    }

使用
button.tag=tag
[按钮设置标签:标签]。您的行
按钮。setTag=tag不会做你认为它会做的事(除非你认为它是胡说八道)。

试试这个

    for (int index = minTag; index <= maxTag;index++) { 
        UIView *aView = [self.view viewWithTag:index];
        if ([aView isKindOfClass:[UIButton Class]]) {
             [aView setUserInterationEnabled:NO];
         }
    }

for(int index=minTag;index多一点上下文会有帮助。您是如何禁用按钮的。它是
button.tag=tag
。button.tag=tag,但它只给出最后一个按钮标记值。您可以显示禁用按钮的代码吗?for(int index=0;index<[objectButtonArray count];index++{UIButton*按钮=[objectButtonArray objectAtIndex:index];button.hidden=NO;imageButton.userInteractionEnabled=NO;}Rahul,请编辑您的问题并在那里提供代码片段..不要将代码放在注释中我可以解释一下(UIView*视图在yourView.subview中)。我无法理解。请。它正在枚举主视图的子视图。您的按钮是主视图的子视图,您将通过此代码获得所有子视图。添加一个逻辑以在此代码中迭代按钮标记,并将此值替换为按钮标记。。。