在iphone的Coverflow图像模板上显示标题

时间:2012-02-16 06:47:01

标签: iphone coverflow

我在我的应用程序中使用CoverFlow,它工作正常但是,我需要显示在封面流中出现的图像标题,使用以下代码添加图像...

loadImagesOperationQueue = [[NSOperationQueue alloc] init];
 for (int i=0; i < 10; i++) 
        {
        imageName = [[NSString alloc] initWithFormat:@"cover_%d.jpg", i];
        [(AFOpenFlowView *)self.view setImage:[UIImage imageNamed:imageName] forIndex:i];
          NSLog(@"my image name is %@",imageName);
        NSLog(@"%d is the index",i);

        }

        [(AFOpenFlowView *)self.view setNumberOfImages:10];

任何人都可以帮助我。下面是我想要实现的屏幕截图。

 ]![enter image description here

2 个答案:

答案 0 :(得分:3)

您只需在方法- (id)initWithFrame:(CGRect)frame{}中为openflow代码中的AFItemView.m类获取一个标签,然后检查类:方法- (void)centerOnSelectedCover:(BOOL)animated{}中的AFOpenFlowView.m,将文本设置为selectedCoverView.label.text=coverImagename;以下。为我工作。

答案 1 :(得分:3)

是的。我必须通过如下:`

- (void)setImage:(UIImage *)image forIndex:(int)index named:(NSString*)imageName{
    // Create a reflection for this image.
    UIImage *imageWithReflection = [image addImageReflection:kReflectionFraction];
    NSNumber *coverNumber = [NSNumber numberWithInt:index];
    [coverImages setObject:imageWithReflection forKey:coverNumber];
    [coverImageHeights setObject:[NSNumber numberWithFloat:image.size.height] forKey:coverNumber];
    [coverImageName setObject:imageName forKey:coverNumber];`

    // If this cover is onscreen, set its image and call layoutCover.
    AFItemView *aCover = (AFItemView *)[onscreenCovers objectForKey:[NSNumber numberWithInt:index]];
    if (aCover) {
        [aCover setImage:imageWithReflection originalImageHeight:image.size.height reflectionFraction:kReflectionFraction named:imageName];

        [self layoutCover:aCover selectedCover:selectedCoverView.number animated:NO];
    }
}`

我传递的图像名称如下:

for (int i=0; i < 10; i++) {
        imageName = [[NSString alloc] initWithFormat:@"cover_%d.jpg", i];UIImage* image_=[UIImage imageNamed:imageName];
        CGFloat width = 290;
        CGFloat height = 200;

        CGSize newSize=CGSizeMake(width, height);
        [(AFOpenFlowView *)self.view setImage:[self imageWithImage:image_ scaledToSize:newSize] forIndex:i named:imageName];
        [imageName release];
        NSLog(@"%d is the index",i);

    }
    [(AFOpenFlowView *)self.view setNumberOfImages:10];