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.
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;
}
}
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
}
}
精彩评论