2011-05-17 79 views
0

尝试使用OpenFlow API for iPhone SDK。 我需要openflow从(图片)链接加载图片。使用XML对象的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

不知道什么“不行”很难说,请澄清并提供您创建的实际URL。

,看起来可疑的唯一线路是这样的一个:

AFGetImageOperation *getImageOperation = [AFGetImageOperation alloc]; 

应该是:

AFGetImageOperation *getImageOperation = [[AFGetImageOperation alloc] init]; 
0

它更容易使用:

NSURL *imageUrl = [[NSURL alloc] initWithString:[@"path/to/the/file.jpg"]; 
NSData *imageData = [NSData dataWithContentsOfURL:imageUrl]; 
UIImage *image = [UIImage imageWithData:imageData]; 

把所有的图像在Array 然后你给你打电话第一个功能

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];