2011-10-21 103 views
0

我是新手機開發人員,我正在努力解決一個問題,我在我的應用程序中使用圖像通過網絡服務捕獲圖像。我的問題是放置在每個表格單元格上的每個圖像都以我的單元格大小壓縮了該圖像大小,但圖像清晰度丟失。請告訴我如何清晰地設置單元格中的圖像。如何設置圖像清晰度?

我很受這個問題,請給我任何建議給我。

你好我與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. 

回答

0

通過使用Lazyloading概念可以讓你的tableview快速滾動。
只需下載this類的lazyloading。

這是很容易推動。

#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; 
} 

之後,畫面清晰度問題:嘗試使用較低分辨率的圖像(50×50)這樣的