尝试使用适用于iPhone SDK的OpenFlow API。 我需要openflow来从(图像)链接加载图片。
这是它始终与本地图像一起使用的方式:
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];
}
但它不起作用。任何人都可以帮助我吗?
答案 0 :(得分:0)
不知道什么“不起作用”很难说,请澄清并提供您正在创建的实际网址。
唯一可疑的是这一行:
AFGetImageOperation *getImageOperation = [AFGetImageOperation alloc];
应该是:
AFGetImageOperation *getImageOperation = [[AFGetImageOperation alloc] init];
答案 1 :(得分:0)
使用起来容易得多:
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];