Well !!!!!
I am here explaining about my app first.
I have 3 UIViews in my main View tagged 111,222,333 and having number of buttons in them.
As ViewWithTag 111 have 16 buttons
As ViewWithTag 222 have 20 buttons
As ViewWithTag 333 have 30 buttons
I am hiding the two view while one is not at a time.
Now the problem is, I want to assign the only image to all of my UIbuttons before the page is loaded开发者_Go百科(In viewWillAppear).
I tried this so far ....
but not working.....
-(void)setBlankImageToButtons
{
UIImage *btnImage = [UIImage imageNamed:@"blue.jpg"];
for (UIView *subview in [self.view subviews])
{
// Only remove the subviews with tag not equal to 1
if (subview.tag != 0)
{
[self.view bringSubviewToFront:[self.view viewWithTag:111]];
NSLog(@"tag is :%d",subview.tag);
if([subview isKindOfClass:[UIButton class]])
{
[(UIButton *)subview setImage:btnImage forState:UIControlStateNormal];
}
}
}
}
warning : 'UIButton' may not respond to '+Class'
It should be [UIButton class]
and not [UIButton Class]
.
Class should be lower case: [UIButton class]
精彩评论