私はObjective-Cプログラミングに不慣れで、データソースとしてXMLファイルを使用するアプリケーションを書いています。私はinitでクラススコアを持っています:
- (id)initWithPlayer1Name:(NSString *)name1 Player2Name:(NSString *)name2 Player1Url:(NSString *)url1 Player2Url:(NSString *)url2 Player1FrameScore:(NSString *)frame1 Player2FrameScore:(NSString *)frame2 Player1InFrameScore:(NSString *)score1 Player2InFrameScore:(NSString *)score2
{
if(self = [super init])
{
self.name1 = name1;
self.name2 = name2;
self.url1 = url1;
self.url2 = url2;
self.image1 = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:url1]]];
self.image2 = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:url2]]];
self.frame1 = frame1;
self.frame2 = frame2;
self.score1 = score1;
self.score2 = score2;
}
return self;
}
そして、スコアのリストをテーブルビューで表示したいと思います。アプリケーションが起動すると、いくつかのサンプルデータがあり、カスタムセルを使用したテーブルビュー(すべての行にスコアクラスからの2つの名前と2つの画像を表示)が正常に機能します。XMLからデータを更新すると問題が発生します(XMLParserを使用しています-うまく機能します)。プレイヤー名は更新されますが、画像が消えます。他のテーブルビューでは、カスタムセルにプレーヤーのリストがありますが、画像は1つだけで、正常に機能します。
スコアテーブルビュークラスのコードは次のとおりです。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"ScoresCell";
ScoresCell *cell = (ScoresCell*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil)
{
cell = (ScoresCell*) [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
Score *score = [self.scores objectAtIndex:indexPath.row];
cell.player1Name.text = score.name1;
cell.player1Image.image = score.image1;
cell.player2Name.text = score.name2;
cell.player2Image.image = score.image1;
return cell;
}
私はそれを多くの方法でテストしていましたが、解決策を見つけられませんでした。