单击子视图时将值设置为superview

时间:2012-04-26 07:35:40

标签: objective-c ios xcode

我动态创建了uiviews,它有很多按钮。它用于从每一行(uiview)中选择特定值(uibutton)。点击按钮时,我必须更改按钮图像(如突出显示)。现在我我是这样的,但订单不匹配。按钮没有在某些行中被选中。请检查下面的代码

for (int j=0; j<[viewTagAry count]; j++)
    {  
        if ([[viewTagAry objectAtIndex:j] isEqualToString:[NSString stringWithFormat:@"%d",v]]) 
        {  
            for (int i=0; i<[lastSelectedButtonAry count]; i++) 
            {
                lastSelectedButton=[lastSelectedButtonAry objectAtIndex:i];
                int tag=[[btnTagArray objectAtIndex:i] intValue];
                UIImage *numImg=[UIImage imageNamed:[NSString stringWithFormat:@"%db.png",tag]];
                [lastSelectedButton setBackgroundImage:numImg forState:UIControlStateNormal];
            }
}
}
-(void)highlightButton:(id)sender{

    UIButton *button = (UIButton *)[sender userInfo];
    int t=button.tag+1;

            UIImage *numImg=[UIImage imageNamed:[NSString stringWithFormat:@"%da.png",t]];
            [button setBackgroundImage:numImg forState:UIControlStateNormal];



}

0 个答案:

没有答案