我想插入和圖像到一個URL的UIImageView。我使用下面的代碼來做到這一點。 運行程序時被卡住在從url下載圖像到UIImageVIew動態
NSURL *url = [NSURL URLWithString:urlstring];
在下面的代碼,它表明:在該特定的行「線程1信號SIGABRT」。 有人可以幫助我,並告訴如果我使用的格式是正確的或我做錯了什麼?
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"newoffer";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (cell==nil)
{
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
NSDictionary *temp = [product objectAtIndex:indexPath.row];
UILabel *Label = (UILabel *)[cell viewWithTag:201];
Label.text = [temp objectForKey:@"item_name"];
UIImageView *Image = (UIImageView *)[cell viewWithTag:200];
NSString *urlstring=[temp objectForKey:@"image_url"];
NSURL *url = [NSURL URLWithString:urlstring];
NSData *data = [NSData dataWithContentsOfURL:url];
Image.image = [UIImage imageWithData:data];
return cell;
}
如果可能,請在此處張貼您的網址 –
如果在我的答案對您有幫助的情況下仍然面臨任何問題,請將我的答案標記爲正確。 –