0

OpenFlow API for iPhone SDK を使用しようとしています。(画像) リンクから画像を読み込むには、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];
}

しかし、それはうまくいきません。誰でも私を助けることができますか?

4

2 に答える 2

0

何が「うまくいかない」のかを知らずに言うのは難しいので、作成している実際の URL を明確にして提供してください。

疑わしいと思われる唯一の行は次のとおりです。

AFGetImageOperation *getImageOperation = [AFGetImageOperation alloc];

次のようにする必要があります。

AFGetImageOperation *getImageOperation = [[AFGetImageOperation alloc] init];
于 2011-05-17T18:46:36.423 に答える
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];
于 2011-07-29T18:41:38.680 に答える