2

UITableViewで画像を含むテキストを解析しようとしていますが、すべての行のテキストしか表示できませんが、画像が表示されません。

これが私のコードです。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [self.anaTablo dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}


    UILabel *textBaslik = (UILabel *) [cell viewWithTag:3];
    UIImage *imagePic = (UIImage *) [cell viewWithTag:7];

    textBaslik.text =[titleArray objectAtIndex:indexPath.row];
    imagePic.images = [imageArray objectAtIndex:indexPath.row];

return cell;

}

しかし、それは機能しませんでした。検索した後、私はこれを試しました。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

    UILabel *textBaslik = (UILabel *) [cell viewWithTag:3];
    UIImage *imagePic = (UIImage *) [cell viewWithTag:7];

    textBaslik.text =[titleArray objectAtIndex:indexPath.row]; 

    NSString *str1 = [[NSString alloc] initWithFormat:@"%@", imageArray];

    NSData *bgImageData = [NSData dataWithContentsOfFile:str1];

    UIImage *img1 = [UIImage imageWithData:bgImageData];

    imagePic = [img1 objectAtIndex:indexPath.row];

return cell

}

私は何か間違ったことをしていますか?Xcodeは初めてです

今からありがとう。

4

2 に答える 2

3

XMLParsesを使用したRSSの解析に関するこのチュートリアルを確認してください。完全に機能します。 WikiXML解析データ

TBXMLフレームワークTBXMLパーサーを使用してこのサンプルコードを確認する必要があります

于 2012-10-11T14:33:43.070 に答える
3

私はあなたのコードをチェックし、私は以下を変更します

NSString *str1 = [[NSString alloc] initWithFormat:@"%@", imageArray];
NSData *bgImageData = [NSData dataWithContentsOfFile:str1];
UIImage *img1 = [UIImage imageWithData:bgImageData];

imagePic = [imageArray objectAtIndex:indexPath.row];

cell.imageView.image=imagePic;

デリゲートメソッドで

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

新しいエラーが表示されたら、確認してください

于 2012-10-11T15:59:48.933 に答える