私はこのプログラミング言語が初めてです...いくつかのサーバーからjsonを消費しようとしましたが、成功した後、すべての情報を消費しましたが、「lazyload」画像をtableviewcellに表示するのに問題があります
私はそれを実現するためにAsyncImageViewを使用します。ここで私のコード
-(UITableViewCell *)tableView :(UITableView *) tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NetraCell *cell =(NetraCell *)[tableView dequeueReusableCellWithIdentifier:@"cell"];
if (cell==nil){
cell=[[NetraCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
//common settings
cell.imageView.contentMode = UIViewContentModeScaleAspectFill;
cell.imageView.frame = CGRectMake(0.0f, 0.0f, 44.0f, 44.0f);
cell.imageView.clipsToBounds = YES;
///get url image from url
//NSString *path=[[[Deals_array objectAtIndex:indexPath.row] objectForKey:@"image"]objectForKey:@"thumbnail"];
////convert image into NSDATA
// NSData* imageData = [NSData dataWithContentsOfURL: [NSURL URLWithString: path]];
////read NSData Image
// UIImage* image = [UIImage imageWithData: imageData];
//////set rounded imager with NetraImage
// image=[ImageManipulator makeRoundCornerImage:image : 30 : 30];
////show image into UItableviewCell
// cell.imageView.image=image;
}
else{
//cancel loading previous image for cell
[[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:cell.imageView];
}
cell.imageView.image = [UIImage imageNamed:@"Placeholder.png"];
cell.imageView.imageURL = [[[imageURLs objectAtIndex:indexPath.row]objectForKey:@"image"]objectForKey:@"thumbnail"];
NSString *price=[[[somearray objectAtIndex:indexPath.row] objectForKey:@"price"]objectForKey:@"formatted"];
///call image from JSOn
///draw to tableviewcell
if(price!=NULL){
cell.detailTextLabel.text= [[[Deals_array objectAtIndex:indexPath.row] objectForKey:@"price"]objectForKey:@"formatted"]; //1 draw the price
//[cell release]
}
else{
cell.detailTextLabel.text= @"Call";
}
//draw headline
cell.textLabel.text=[[Deals_array objectAtIndex:indexPath.row] objectForKey:@"headline"];
///draw image
[UIApplication sharedApplication].networkActivityIndicatorVisible=NO;
return cell;
}
この行は私の画像のパスです
//NSString *path=[[[Deals_array objectAtIndex:indexPath.row] objectForKey:@"image"]objectForKey:@"thumbnail"];
これは、pic を uitableviewcell に割り当てるデフォルトの方法です。
cell.imageView.imageURL = [imageURLs objectAtIndex:indexPath.row];
しかし、この方法を試すと
cell.imageView.imageURL = [[[imageURLs objectAtIndex:indexPath.row]objectForKey:@"image"]objectForKey:@"thumbnail"];
そのエラー、主な質問は
- なぜエラー?それは私のリモートイメージパスが間違っていますか? または私の方法が間違っている
あなたの助けが必要です:)どうもありがとう