How to setTitle of a UIButton with a specific tag?
We can get a view with a specific tag using viewWi开发者_如何学CthTag method, like
[sampleView viewWithTag:1];
But how can we setTitle of a UIButton with specific tag??
From this answer here, it used the following code to set the alpha. But setTitle will not respond to viewWithTag right?
UIView* view = [theViewContainingThatButton viewWithTag:tag];
view.alpha = 0.5;
I even tried this question, but no luck!!
What else I can do here?
Thanx :)
UIButton* aButton = (UIButton *) [theViewContainingThatButton viewWithTag:tag];
[aButton setTitle:@"clickeme" forState:UIControlStateNormal];
The following should work:
UIButton *button = (UIButton *)[theViewContainingThatButton viewWithTag:tag];
[button setTitle:@"Button Title" forState:UIControlStateNormal];
Remember that a UIButton
does not respond to setTitle:
, but does respond to setTitle:forState:
精彩评论