URL から XML ファイルを取得しています。解析して画像を取得しました。私のXMLファイルは次のように構成されています。
<Products>
<products id="1">
<img>http://images.com/images/image1.jpg</img>
</products>
<products id="2">
<img>http://images.com/images/image2.jpg</img>
</products>
<products id="3">
<img>http://images.com/images/image3.jpg</img>
</products>
</Products>
Tableviewcontroller.m には次のようなコードがあります。
- (void)viewDidLoad{
[super viewDidLoad];
xmlParser = [[XMLParser alloc] loadXMLByURL:@"http://images.com/Products.xml"];
[self.tableView reloadData];}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [xmlParser.tweets count];}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Products";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];}
UIImage *currentTweet = [[xmlParser tweets] objectAtIndex:1];
cell.imageView.image = currentTweet;
[cell.contentView addSubview:self.productImage];
return cell;}
ここで、xmlParser はクラス XMLParser のオブジェクトで、tweets は配列です。商品画像はUIImageviewのリファレンスです。今私の問題は、アプリを実行すると、テーブルビューに画像がサムネイル画像として表示されることですが、下のスクリーンショットのように画像を表示したいです。
また、ストーリーボードでUIImageビューを参照する際に混乱しています.hファイルでproductImageをUIImageViewとして定義し、ストーリーボードに接続しようとすると、Illegal Configurationのようなエラーが表示されます:接続 "productImage"はプロトタイプオブジェクトを宛先として持つことができません. ストーリーボードでも接続する方法を教えてください。
これを解決するために私に親切に提案してください、