set Image to Button
Posted
by Ivan
on Stack Overflow
See other posts from Stack Overflow
or by Ivan
Published on 2010-05-04T19:22:49Z
Indexed on
2010/05/04
19:28 UTC
Read the original article
Hit count: 354
Hello all,
Could somebody help me a little bit with my issue below?
When I call the myFunction, images which I want to set to buttons appear after 2 sec simultaneously, not one by one with delay of 0.5 sec.
More info:
- generatedNumbers is array with four elements of NSNumber (4,1,3,2)
- buttons are set in UIView via IB and are tagged (1,2,3,4)
-(IBAction) myFunction:(id) sender {
int i, value;
for (i = 0; i<[generatedNumbers count]; i++) {
value = [[generatedNumbers objectAtIndex:i] intValue];
UIButton *button = (UIButton *)[self.view viewWithTag:i+1];
UIImage *img = [UIImage imageNamed:[NSString stringWithFormat:@"%d.png",value]];
[button setImage:img forState:UIControlStateNormal];
[img release];
usleep(500000);
}
}
© Stack Overflow or respective owner