Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 大型UIImage drawinrect在选择时非常慢_Iphone_Uitableview_Uiimage - Fatal编程技术网

Iphone 大型UIImage drawinrect在选择时非常慢

Iphone 大型UIImage drawinrect在选择时非常慢,iphone,uitableview,uiimage,Iphone,Uitableview,Uiimage,我有一个自定义的UITableView单元格,其中显示图像和标题。我使用了atebits中ABTableViewCell的快速滚动示例 似乎当我选择第一行(这是我的图像最大的行)时,高亮显示该行需要相当长的时间,然后按下新的视图控制器 然而,当我选择其他任何一行时,图像要小得多,它几乎是即时的 我曾尝试使用CGContextDrawImage和drawInRect绘制图片,但都得到了相同的结果 - (void)drawContentView:(CGRect)r highlighted:(BOOL

我有一个自定义的UITableView单元格,其中显示图像和标题。我使用了atebits中ABTableViewCell的快速滚动示例

似乎当我选择第一行(这是我的图像最大的行)时,高亮显示该行需要相当长的时间,然后按下新的视图控制器

然而,当我选择其他任何一行时,图像要小得多,它几乎是即时的

我曾尝试使用CGContextDrawImage和drawInRect绘制图片,但都得到了相同的结果

- (void)drawContentView:(CGRect)r highlighted:(BOOL)highlighted {
 if ([type isEqualToString:@"first"]) {
   CGContextRef context = UIGraphicsGetCurrentContext();
   UIColor *backgroundColor = [UIColor blackColor];
   UIColor *textColor = [UIColor whiteColor];
   UIColor *textBackgroundColor = [[UIColor alloc] initWithWhite:0 alpha:.5];
   UIColor *highlightColor;
   if (highlighted) {
     backgroundColor = [UIColor clearColor];
     textColor = [UIColor blueColor];
     highlightColor = [[UIColor alloc] initWithWhite:0 alpha:.3];
   } else {
     highlightColor = [UIColor clearColor];
   }

   [backgroundColor set];
   CGContextFillRect(context, r);
   [self.picture drawInRect:CGRectMake(0.0, 0.0, 320, 225)];
   [textBackgroundColor set];
   CGContextFillRect(context, CGRectMake(0, 170, 320, 55));  
   [textColor set];

   [self.title drawInRect:CGRectMake(5, 170, 320, 55) withFont:firstHeadlineFont lineBreakMode:UILineBreakModeWordWrap];
   [highlightColor set];
   CGContextFillRect(context, r);
 } else {
   CGContextRef context = UIGraphicsGetCurrentContext();
   UIColor *backgroundColor = [UIColor blackColor];
   UIColor *textColor = [UIColor blueColor];

   if (highlighted) {
     backgroundColor = [UIColor clearColor];
     textColor = [UIColor whiteColor];
   }
   [backgroundColor set];
   CGContextFillRect(context, r);

   CGPoint p;
   p.x = 0;
   p.y = 0;
   [self.picture drawInRect:CGRectMake(0.0, 0.0, 44, 44)];

   [textColor set];
   p.x += 44 + 6; // space between words
   [self.title drawAtPoint:p withFont:[UIFont systemFontOfSize:20]];
 }
}
编辑:
我能做些什么来加快速度吗?我正在缓存图像并读取它。

我意识到我在第一行中使用了非常大的图像版本,在从Web服务器中取出它之前,我能够将其缩小,这大大提高了性能。注意:仔细检查您的尺寸是否过大。IE:2184x1456哈哈