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

发布于 2025-01-06 06:25:25 字数 637 浏览 0 评论 0原文

我在我的应用程序中使用 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];

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

 ]![在此处输入图像描述

I am using CoverFlow in my application ,it is working fine but, I need to display the title of image that appears to front in coverflow,To add images iam usinf following code...

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

Can any one help me out.Below is the screenshot I would like to implement.

 ]![enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你的心境我的脸 2025-01-13 06:25:25

是的。你必须像下面这样传递:`

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

yes.U have to pass like below:`

- (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];
    }
}`

and i pass the image name like below:

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];
帅气尐潴 2025-01-13 06:25:25

您只需在 openflow 代码中的 AFItemView.m 类的 method- (id)initWithFrame:(CGRect)frame{} 中获取一个标签,并在方法 - ( void)centerOnSelectedCover:(BOOL)animated{} 设置文本如下selectedCoverView.label.text=coverImagename;。这对我有用。

You simply take a label in method- (id)initWithFrame:(CGRect)frame{} for class AFItemView.m in openflow code and check in the class:AFOpenFlowView.m in method - (void)centerOnSelectedCover:(BOOL)animated{} set text as belowselectedCoverView.label.text=coverImagename;.This worked for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文