2011-08-24 25 views
3

如何將下載的圖像放入單元格中?UITableView和ASIHTTPRequest

我不知道如何將響應數據加載到cell.imageView.image中。

下面是代碼:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    .... 
    .... 
    NSURL *photoURL = [NSURL URLWithString:user.photo]; 
    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:photoURL]; 
    [request setDownloadCache:[ASIDownloadCache sharedCache]]; 
    [request setDelegate:self]; 
    [request startAsynchronous]; 
    cell.textLabel.text = [NSString stringWithFormat:@"%@ %@",user.first_name,user.last_name]; 
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 

    //image loaded 
    - (void)requestFinished:(ASIHTTPRequest *)request 
    { 
     NSData *responseData = [request responseData]; 
    } 

回答

2

Here是一個示例代碼有一個引導線和a brief description.

+0

是它自定義單元格? –

+0

是的,** FlickrCell **是一個自定義單元格。 –