带图像的快速滚动表格单元格。这是怎么做的? [英] Fast Scrolling table cells with images. Is this how it is done?

查看:169
本文介绍了带图像的快速滚动表格单元格。这是怎么做的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用Tweetie的创建者创建一个快速滚动列表,Loren Brichter的技术(或这种技术)。我相信这个想法是做你自己的绘图而不是使用UITableViewCell中的子视图和图像。

I'm try to create a fast scrolling list using the creator of Tweetie, Loren Brichter's technique (or this technique). I believe the idea is to "do your own drawing" instead of using using subviews and images in the UITableViewCell.

下面我将他的示例扩展为包含图像,我不确定这是否是正确的方法?

Below I have extend his example to include an image and I'm not sure if this is the correct way to do it?

我一直在尝试和CALayer一起玩,并且正在努力搞定。所以在这个例子中我刚刚绘制了一个图像。但我不确定 - 这看起来与图像在视图中的显示方式相同?接下来我将使用UIGraphicsBeginImageContext来包含更多图像(例如footerImage)

I have been trying to play around with CALayer and am struggling to 'get it'. So here in this example I just drawn out an image. But I'm unsure – this seems the same as how an image is displayed in a view? Next I will use UIGraphicsBeginImageContext to include more images (e.g. footerImage)

我在这个例子中正在做什么来提高性能而不是在IB中创建它?

Is what I am doing in this example going to improve performance over creating it all in IB?

谢谢

- (void)drawContentView:(CGRect)r
{
    CGContextRef context = UIGraphicsGetCurrentContext();

    UIColor *backgroundColor = [UIColor whiteColor];
    UIColor *textColor = [UIColor blackColor];

    if(self.selected)
    {
        backgroundColor = [UIColor clearColor];
        textColor = [UIColor whiteColor];
    }

    [backgroundColor set];
    CGContextFillRect(context, r);

    // This is where I add the image to the example
    //
    CGRect profile = CGRectMake(0, 0, 320, 20);
    [headerImage drawInRect:profile];

    CGPoint p;
    p.x = 12;
    p.y = 9;

    [textColor set];
    CGSize s = [firstText drawAtPoint:p withFont:firstTextFont];

    p.x += s.width + 6; // space between words
    [lastText drawAtPoint:p withFont:lastTextFont];
}


推荐答案

是的,这种技术会有所改善直接IB细胞的表现。但是如果你让单元格的所有元素都不透明,那么IB的表现可能相当不错 - 你可能想先尝试一下,然后再沿着大量代码的路径去创建简单的单元格。

Yes, this technique will improve performance over a straight IB cell. But if you make all elements of a cell opaque, IB performance can be pretty decent - you may want to try that first before you go down the path of a lot of code to create what are otherwise simple cells.

这篇关于带图像的快速滚动表格单元格。这是怎么做的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆