I've been searching all over the net for an answer to this one! Hoping one of you can help me.
So far I have a button that produces a random nr between 1 and 6 in a label.
Then I want a picture to appear depending on what nr is in the label.
For example: If the number 1 is generated, I want img1.png to appear in a UIImageView.(?) I'm thinking maybe a if function to pick the picture?
Sorry for bad formating.
Here is the .h file:
#import <UIKit/UIKit.h>
@interface xxxViewController : UIViewController
{
IBOutlet UILabel *label;
int randomNumber;
}
-(IBAction)randomize;
@end
...and here is the .m file:
#import "xxxViewController.h"
@implementation xxxViewController
-(IBAction)randomize
{
int randomNumber = 1+ arc4random() %(6);
label .text = [NSString stringWithFormat:@"%d",randomNumber];
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
int randomNumber = 1+ arc4random() %(6);
label .text = [NSString stringWithFormat:@"%d",randomNumber];
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end