我是 iOS 编程的新手。我正在从服务器获取图像和音频文件。之后,使用下面的代码,我试图将所有图像显示为缩略图。谁能告诉我如何将所有图像显示为缩略图。也没有播放音频。
-(IBAction)fullsizeimage:(id)sender
{
////////////// Image ////////////////////////////
NSURL *url = [NSURL URLWithString:@"http://182.73.152.59:82/php/tauky_services/codeigniter-restserver-master/uploads/45/thumbnail_small/326.png"];
NSData *data = [NSData dataWithContentsOfURL: url];
UIImage *image = [UIImage imageWithData:data];
imagee = [[UIImageView alloc] initWithImage: image];
[self.view addSubview:imagee];
NSURL *url1 = [NSURL URLWithString:@"http://182.73.152.59:82/php/tauky_services/codeigniter-restserver-master/uploads/45/thumbnail_small/327.png"];
NSData *data1 = [NSData dataWithContentsOfURL: url1];
UIImage *image1 = [UIImage imageWithData:data1];
imagee1 = [[UIImageView alloc] initWithImage: image1];
[self.view addSubview:imagee1];
NSURL *urll = [NSURL URLWithString:@"http://182.73.152.59:82/php/tauky_services/codeigniter-restserver-master/uploads/45/thumbnail_small/325.png"];
NSData *dataa = [NSData dataWithContentsOfURL: urll];
UIImage *imageee = [UIImage imageWithData:dataa];
imagee2 = [[UIImageView alloc] initWithImage: imageee];
[self.view addSubview:imagee2];
/////////////// Audio ///////////////////////
NSURL *audiourl = [NSURL URLWithString:@"http://182.73.152.59:82/php/tauky_services/codeigniter-restserver-master/uploads/45/Audio/312.mp3"];
NSData *audioData = [NSData dataWithContentsOfURL:audiourl];
NSError *error;
//AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:audioData error:&error];
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithData:audioData error:&error];
audioPlayer.numberOfLoops = -1;
if (audioPlayer == nil)
NSLog([error description]);
else
[audioPlayer play];
}
谢谢阿斯拉姆