3
我這樣做:如何在UITableViewCell中顯示圖像來自NSMutableArray?
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier];
cell.imageView.image = [UIImage imageNamed:[[self.articlesArray
objectAtIndex:indexPath.row]objectForKey:@"images"]];
// [cell.imageView setImageWithURL:[NSURL URLWithString:[[self.articlesArray
objectAtIndex:indexPath.row]objectForKey:@"images"]]];
}
return cell;
}
我這樣做:
cell.imageView.image = [UIImage imageNamed:[[self.articlesArray
objectAtIndex:indexPath.row]objectForKey:@"images"]];
但沒有什麼是顯示在我的UITableViewCell
。
而且我想表現出對tableViewCell
在左側左側圖像,
請告訴我,我怎麼能做到這一點。
請確認'self.articlesArray'被初始化,每個條目都包含一個帶有「images」鍵的字典,key「images」指向一個NSString並且圖像存在於主包中因爲你使用'imageNamed:')。 – StatusReport
yes self.articlesArray被初始化,並且每個條目都包含一個帶有指向NSString的鍵'images'的字典,如下所示:「http://www.dem......p-content/uploads/2011/05 /learn_t.jpg「 –
您發佈的網址不完整。嘗試將'[UIImage imageNamed:]'的返回值設置爲一個變量,並通過調試來驗證它不是零。 – StatusReport