applelover
applelover

Reputation: 136

Hidden the button in same subview

for (id btn in [searchMenu subviews]) {
    if([btn isKindOfClass:[UIButton class]]){
        if ([btn tag]>=1 && [btn tag]<=3) {
            if ([btn tag]==flag) {
                [btn setBackgroundImage:[UIImage imageNamed:@"all_news_bg.png"] forState:UIControlStateNormal];
            }else {
                [btn setBackgroundImage:nil forState:UIControlStateNormal];
            }
        }
    }
}

I have five button on searchMenu subview... when button i am clicking the btn tag 3 i need to hidden the btn tag 11.... How to do?

In the search menu subview five button tags are 0,1,2,3,11

I need to hidden the button tag 11 when i click button tag 3.

@Thanks in advance.

Upvotes: 0

Views: 375

Answers (2)

HCharli
HCharli

Reputation: 361

Implement this code in the interface action method of the button with tag 3.

for( UIView *view in self.view.subviews ) {  
    if( [view isKindOfClass:[UIButton class]] ) {  
        if( view.tag == 11 )
            [view removeFromSuperview];// You can hide or remove   
    }  
}

Upvotes: 1

Jhaliya - Praveen Sharma
Jhaliya - Praveen Sharma

Reputation: 31722

You must be receiving your UIButtons pressed event in an one method,

Let's assume that's buttonClicked:

-(void) buttonClicked:(id) sender
{
   UIButton* myButton = (UIButton*) sender;
   if(myButton.tag == 3)
   { 
     UIButton* buttonWithTaged11 = [myButton.superview viewWithTag:11];
     if(buttonWithTaged11)
         buttonWithTaged11.hidden = YES;
   }

}

Upvotes: 1

Related Questions