gpt4 book ai didi

objective-c - 播放声音与显示的图像一一对应

转载 作者:行者123 更新时间:2023-11-29 04:59:51 26 4
gpt4 key购买 nike

我有十个图像文件和声音文件,当我显示“a.png”时,我想播放“a.mp3”。然后,当我单击“下一步”按钮时,显示“b.png”并播放“b.mp3”。我该如何解决这个问题?

最佳答案

-(void) viewDidLoad;{


sounds = [[NSArray alloc]initWithObjects:@"a.mp3", @"b.mp3",@"c.mp3", nil];


imageArray = [[NSArray arrayWithObjects:
[UIImage imageNamed:@"a.jpg"],
[UIImage imageNamed:@"b.jpg"],
[UIImage imageNamed:@"c.jpg"],
nil] retain];
[super viewDidLoad];}
-(IBAction) next; {
currentSound++;
if (currentSound >= sounds.count) currentSound = 0;
//what kind of code play this sound////images work perpectly but sound not//


currentImage++;
if (currentImage >= imageArray.count) currentImage = 0;
UIImage *img = [imageArray objectAtIndex:currentImage];
[imageView setImage:img];}

关于objective-c - 播放声音与显示的图像一一对应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7222458/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com