#iphone #coverflow
#iPhone #coverflow
Вопрос:
Пытаюсь использовать OpenFlow API для iPhone SDK. Мне нужен openflow для загрузки изображений по ссылке (image).
Вот как это всегда работает с локальными изображениями:
loadImagesOperationQueue = [[NSOperationQueue alloc] init];
NSString *imageName;
for (int i=0; i < 10; i ) {
imageName = [[NSString alloc] initWithFormat:@"cover_%d.jpg", i];
[(AFOpenFlowView *)self.view setImage:[UIImage imageNamed:imageName] forIndex:i];
[imageName release];
NSLog(@"%d is the index",i);
}
[(AFOpenFlowView *)self.view setNumberOfImages:10];
И я попробовал это:
- (void)openFlowView:(AFOpenFlowView *)openFlowView requestImageForIndex:(int)index {
NSString *photoUrl = [[oldEntries objectAtIndex: 0] objectForKey: @"still"];
NSURL *photomake = [NSURL URLWithString:photoUrl];
NSLog(@"theConnection: %@",photoUrl);
NSLog(@"theConnection: %@",photomake);
AFGetImageOperation *getImageOperation = [AFGetImageOperation alloc];
// We're getting our images from the Flickr API.
getImageOperation.imageURL = photomake;
[loadImagesOperationQueue addOperation:getImageOperation];
[(AFOpenFlowView *)self.view setNumberOfImages:1];
[getImageOperation release];
}
Но это просто не сработает. Кто-нибудь может мне помочь?
Ответ №1:
Без знания того, что «не сработает», трудно сказать, пожалуйста, уточните и укажите фактический URL, который вы создаете.
Единственная строка, которая выглядит подозрительной, — это эта:
AFGetImageOperation *getImageOperation = [AFGetImageOperation alloc];
Должно быть:
AFGetImageOperation *getImageOperation = [[AFGetImageOperation alloc] init];
Ответ №2:
Это намного проще в использовании:
NSURL *imageUrl = [[NSURL alloc] initWithString:[@"path/to/the/file.jpg"];
NSData *imageData = [NSData dataWithContentsOfURL:imageUrl];
UIImage *image = [UIImage imageWithData:imageData];
поместите все изображения в массив
и затем вы вызываете свою первую функцию
for (int i=0; i < 10; i ) {
imageName = [[NSString alloc] initWithFormat:@"cover_%d.jpg", i];
[(AFOpenFlowView *)self.view setImage:**image** forIndex:i];
[imageName release];
NSLog(@"%d is the index",i);
}
[(AFOpenFlowView *)self.view setNumberOfImages:10];