Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import "PlayViewController.h"
- @interface PlayViewController ()
- @end
- @implementation PlayViewController
- @synthesize b1;
- @synthesize b2;
- @synthesize b3;
- @synthesize b4;
- @synthesize b5;
- @synthesize b6;
- @synthesize b7;
- @synthesize b8;
- @synthesize b9;
- @synthesize tv;
- @synthesize imageArray;
- @synthesize textArray,player;
- @synthesize image;
- @synthesize combinedarray;
- @synthesize soundArray;
- @synthesize dict;
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
- {
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- // Custom initialization
- }
- return self;
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"learn_page.jpg"]];
- [[self view] setBackgroundColor:background];
- textArray =[[NSMutableArray alloc] initWithObjects:
- @"circle",@"crescent",@"curvilinear_triangle",@"ellipse",
- @"heptagon",@"kite",@"oval",@"paralelogram",@"pentagon",
- @"rectangle",@"square",@"triangle",@"blue-jay",@"cardinal",
- @"crow",@"duck",@"hawk",@"hummingbird",@"owl"@"parrot",
- @"peacock",@"robin",@"sparrow",@"woodpecker",@"elephant",
- @"cow",@"horse",@"kangaroo",@"lion",@"monkey",@"mouse",
- @"panda",@"rabbit",@"sheep",@"zebra",nil];
- soundArray = [[NSMutableArray alloc] initWithObjects:
- @"circle.mp3",@"crescent.mp3",@"curvilinear_triangle.mp3",
- @"ellipse.mp3",@"heptagon.mp3",@"kite.mp3",@"oval.mp3",
- @"paralelogram.mp3",@"pentagon.mp3",@"rectangle.mp3",
- @"square.mp3",@"triangle.mp3",@"blue-jay.mp3",@"cardinal.mp3",
- @"crow.mp3",@"duck.mp3",@"hawk.mp3",@"hummingbird.mp3",
- @"owl.mp3"@"parrot.mp3",@"peacock.mp3",@"robin.mp3",
- @"sparrow.mp3",@"woodpecker.mp3",@"elephant.mp3",@"cow.mp3",
- @"horse.mp3",@"kangaroo.mp3",@"lion.mp3",@"monkey.mp3",
- @"mouse.mp3",@"panda.mp3",@"rabbit.mp3",@"sheep",@"zebra",nil];
- NSMutableArray *imagearray = [[NSMutableArray alloc]initWithObjects:
- [UIImage imageNamed:@"circle.png"],
- [UIImage imageNamed:@"crescent.png"],
- [UIImage imageNamed:@"curvilinear_triangle.png"],
- [UIImage imageNamed:@"ellipse.png"],
- [UIImage imageNamed:@"heptagon.png"],
- [UIImage imageNamed:@"kite.png"],
- [UIImage imageNamed:@"oval.png"],
- [UIImage imageNamed:@"paralelogram.png"],
- [UIImage imageNamed:@"pentagon.png"],
- [UIImage imageNamed:@"rectangle.png"],
- [UIImage imageNamed:@"square.png"],
- [UIImage imageNamed:@"triangle.png"],
- [UIImage imageNamed:@"blue-jay.png"],
- [UIImage imageNamed:@"cardinal.png"],
- [UIImage imageNamed:@"crow.png"],
- [UIImage imageNamed:@"duck.png"],
- [UIImage imageNamed:@"hawk.png"],
- [UIImage imageNamed:@"hummingbird.png"],
- [UIImage imageNamed:@"owl.png"],
- [UIImage imageNamed:@"parrot.png"],
- [UIImage imageNamed:@"peacock.png"],
- [UIImage imageNamed:@"robin.png"],
- [UIImage imageNamed:@"sparrow.png"],
- [UIImage imageNamed:@"woodpecker.png"],
- [UIImage imageNamed:@"elephant.png"],
- [UIImage imageNamed:@"cow.png"],
- [UIImage imageNamed:@"horse.png"],
- [UIImage imageNamed:@"kangaroo.png"],
- [UIImage imageNamed:@"lion.png"],
- [UIImage imageNamed:@"monkey.png"],
- [UIImage imageNamed:@"mouse.png"],
- [UIImage imageNamed:@"panda.png"],
- [UIImage imageNamed:@"rabbit.png"],
- [UIImage imageNamed:@"sheep.png"],
- [UIImage imageNamed:@"tiger.png"],
- [UIImage imageNamed:@"zebra.png"],nil];
- NSMutableArray *Dupimages = [[NSMutableArray alloc]initWithArray:image];
- NSMutableArray *randomImages = [[NSMutableArray alloc]init];
- [b1 setBackgroundImage:[randomImages objectAtIndex:0] forState:UIControlStateNormal];
- [b2 setBackgroundImage:[randomImages objectAtIndex:1] forState:UIControlStateNormal];
- [b3 setBackgroundImage:[randomImages objectAtIndex:2] forState:UIControlStateNormal];
- [b4 setBackgroundImage:[randomImages objectAtIndex:3] forState:UIControlStateNormal];
- [b5 setBackgroundImage:[randomImages objectAtIndex:4] forState:UIControlStateNormal];
- [b6 setBackgroundImage:[randomImages objectAtIndex:5] forState:UIControlStateNormal];
- [b7 setBackgroundImage:[randomImages objectAtIndex:6] forState:UIControlStateNormal];
- [b8 setBackgroundImage:[randomImages objectAtIndex:7] forState:UIControlStateNormal];
- [b9 setBackgroundImage:[randomImages objectAtIndex:8] forState:UIControlStateNormal];
- int rendom=arc4random()%9;
- [tv setText:[textArray objectAtIndex:rendom]];
- NSString *url=[NSString stringWithFormat:@"%@",tv.text];
- NSLog(@"%@",url);
- NSString *soundPath =[[NSBundle mainBundle] pathForResource:url ofType:@"mp3"];
- NSURL *soundURL = [NSURL fileURLWithPath:soundPath];
- NSError *error;
- player=[[AVAudioPlayer alloc]initWithContentsOfURL:soundURL error:&error];
- player.volume=1.0;
- player.delegate=self;
- [player play];
- }
- -(void) randomText
- {
- }
- -(IBAction)b1:(id)sender{
- NSString *myString = [NSString stringWithFormat:@"%d",[[imageArray objectAtIndex:0]integerValue]];
- tv.text=myString;
- }
- -(IBAction)b2:(id)sender{
- NSString *myString = [NSString stringWithFormat:@"%d",[[imageArray objectAtIndex:1] intValue]];
- tv.text=myString;
- }
- -(IBAction)b3:(id)sender{
- NSString *myString = [NSString stringWithFormat:@"%d",[[imageArray objectAtIndex:2] intValue]];
- tv.text=myString;
- }
- -(IBAction)b4:(id)sender{
- NSString *myString = [NSString stringWithFormat:@"%d",[[imageArray objectAtIndex:3] intValue]];
- tv.text=myString;
- }
- -(IBAction)b5:(id)sender{
- NSString *myString = [NSString stringWithFormat:@"%d",[[imageArray objectAtIndex:4] intValue]];
- tv.text=myString;
- }
- -(IBAction)b6:(id)sender{
- NSString *myString = [NSString stringWithFormat:@"%d",[[imageArray objectAtIndex:5] intValue]];
- tv.text=myString;
- }
- -(IBAction)b7:(id)sender{
- NSString *myString = [NSString stringWithFormat:@"%d",[[imageArray objectAtIndex:6] intValue]];
- tv.text=myString;
- }
- -(IBAction)b8:(id)sender{
- NSString *myString = [NSString stringWithFormat:@"%d",[[imageArray objectAtIndex:7] intValue]];
- tv.text=myString;
- }
- -(IBAction)b9:(id)sender{
- NSString *myString = [NSString stringWithFormat:@"%d",[[imageArray objectAtIndex:8] intValue]];
- tv.text=myString;
- }
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement