【问题标题】:How to set the image clarity?如何设置图像清晰度?
【发布时间】:2011-10-21 10:31:17
【问题描述】:

我是新的 i 手机开发人员,我正在努力解决一个问题,我在我的应用程序中使用了通过 Web 服务捕获的图像。我的问题是放置在每个表格单元格上的每个图像,我以我的单元格大小压缩了该图像大小,但图像清晰度缺失。请告诉我如何清晰地设置单元格中的图像。

我很受这个问题的困扰,请给我任何建议。

您好,我正在使用 Twitter,我的图片有问题,我的推文视图有 UITableview,它包含所有带有用户照片的推文,如果我在滚动 UITableview 时将这些照片加载到每个单元格中,它会滚动非常非常缓慢请建议我减少照片的内存大小并快速滚动 UITableView。

我听说缩略图可以减少内存大小,是吗?(如果不是,我必须选择哪种方法以及缩略图方法做什么)如果是这样,如何在此代码中执行此操作(表格视图单元格代码) 我听说缩略图可以减少内存大小,是吗?(如果不是,我必须选择哪种方法以及缩略图方法是什么)如果是这样,如何在此代码中执行此操作(表格视图单元格代码)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

 static NSString *identifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];


if(!cell) {

    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewStyleGrouped reuseIdentifier:nil] autorelease];

UIImageView *myImage = [[UIImageView alloc]initWithFrame:CGRectMake(6,10,58,60)] ;

NSURL *url = [NSURL URLWithString:[(Tweet*)[tweetArray objectAtIndex:indexPath.row] image_url]]; //here Tweet is other class and image_url is method in the Tweet class

NSData *data = [[NSData alloc] initWithContentsOfURL:url];

[myImage setImage: [UIImage imageWithData:data]];

[cell.contentView addSubview:myImage];

[myImage release];  

}

return cell;
}

Thanks in advance.

【问题讨论】:

    标签: iphone ios image uiimageview


    【解决方案1】:

    通过使用延迟加载概念,您可以使您的表格视图快速滚动。
    只需下载 this 类进行延迟加载。

    这是很容易的。

     #import "UIImageView+WebCache.h"  // Import this
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
         ------------------ 
         ------------------
    [cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]  placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
    
        cell.textLabel.text = @"My Text";
        return cell;
    }
    

    然后是图片清晰度问题:尽量使用分辨率较低的图片(50x50)这样

    【讨论】:

      猜你喜欢
      • 2013-07-27
      • 2015-04-27
      • 1970-01-01
      • 1970-01-01
      • 2020-04-25
      • 1970-01-01
      • 2016-08-26
      • 2017-05-15
      • 2012-12-07
      相关资源
      最近更新 更多