iphone SDK can xcode get the objects created in interface builder?
-
28-09-2019 - |
Question
Can I get the objects created in Interface builder in xcode by program ?
I have set the tag and name of the objects (UIButton). The situation is that I used IBAction for "button pressed" action and I can get the current button which trigger the action, but what if I want to get the previous pressing button and set its image?
any suggestions would help !
Solution
if you know the tag you can get the UIButton with something like this:
UIButton *button = [self.view viewWithTag:42];
[button setImage....
If you change the image often I would recommend an IBOutlet which is connected to you button.
If you really need the last button you could store it somewhere, preferable in an ivar.
- (IBAction)buttonAction:(id)sender {
[lastButton setImage:....];
[sender doSomething];
lastButton = sender;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow