テーブルビューに異なる画像を表示したい。私はsqliteにイメージ名を格納しました。だから、データベースからイメージ名を尋ねるだけでよいと思うたびに、sqliteのUITableView画像
cell.imageView.image = [UIImage imageNamed:[@"%@.jpg",[self.arraySonglistInfo objectAtIndex:indexPath.row] objectAtIndex:picture]]
がありますが、何か問題があります。私はここで何をすべきですか? 方法は次のとおりです。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
// Configure the cell...
NSInteger picture = [self.database.arrayColumnNames indexOfObject:@"picture"];
cell.imageView.image = [UIImage imageNamed:[@"%@.jpg",[self.arraySonglistInfo objectAtIndex:indexPath.row] objectAtIndex:picture]];
return cell;
}
エラーが
Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 3 beyond bounds [0 .. 2]'
され、警告 "未使用の式の結果は" この行にあります:
cell.imageView.image = [UIImage imageNamed:[@"%@.jpg",[self.arraySonglistInfo objectAtIndex:indexPath.row] objectAtIndex:picture]];
さらに進んでいく必要があります。どのようなエラーがありましたか?何が悪かったのか?どのような方法の中で、そのコード行を入れましたか? –
更新しました、ありがとうございます! – Xie