1

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

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

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

]![在此处输入图片说明

4

2 回答 2

3

您只需- (id)initWithFrame:(CGRect)frame{}在 openflow 代码中为类 AFItemView.m 的方法中取一个标签,然后在方法- (void)centerOnSelectedCover:(BOOL)animated{}集文本中检查类:AFOpenFlowView.m,如下所示selectedCoverView.label.text=coverImagename;。这对我有用。

于 2012-02-16T07:26:56.350 回答
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];
于 2012-02-16T08:58:59.467 回答