1

我已经使用http://chaosinmotion.com/flowcover.m这个链接实现了coverFlow 。它工作正常。我想通过网络服务获取coverFlow 图像。它适用于单个图像。任何人都向我发送用于在具有多个图像属性的单个 url 中获取多个coverFlow 图像的代码。后端的任何更改都应反映在代码中,如果没有增加图像,那么在coverflow 中也会显示相同的编号。的图像。

4

1 回答 1

0

在 CoverFlowViewController.h 文件中

NSMutableArray *profilephotos;    // declare NSMutableArray

在 CoverFlowViewController.m 文件中

- (void)viewDidLoad 
{
    profilephotos = [[NSMutableArray alloc] initWithObjects:@"www.xxxx.com/ima.jpeg",@"www.xxxx.com/ima1.jpeg",@"www.xxxx.com/ima2.jpeg",@"www.xxxx.com/ima3.jpeg",@"www.xxxx.com/ima4.jpeg",@"www.yyy.com/ima5.jpeg",nil];
    NSLog(@"profilephotos = %@",profilephotos);  // Your array of Images url
    loadImagesOperationQueue = [[NSOperationQueue alloc] init];

    for (int i=0; i < [profilephotos count]; i++)
    {
        NSString *pho = [profilephotos objectAtIndex:i];
        NSURL *url = [NSURL URLWithString:pho];
        NSData *data = [NSData dataWithContentsOfURL: url];
        UIImage *img=[UIImage imageWithData:data];

        CGSize newSize = CGSizeMake(300.0f, 300.0f);
        UIGraphicsBeginImageContext(newSize);
        [img drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
        UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();

        [(AFOpenFlowView *)self.view setImage:newImage forIndex:i];
    }
    [(AFOpenFlowView *)self.view setNumberOfImages:[profilephotos count]];
}
于 2012-07-10T08:14:19.823 回答