2012-01-26 20 views
-1

テキストフィールドから取り込んだテキストとフォトアルバムから取り込んだ画像をUITableViewCellに追加しようとしています。画像とテキストをテーブルビューに追加

UIViewController私はUITextFieldUIImageViewを持っています。これは、 にあるコードで、UITableViewのセルに表示される製品の配列に値を設定します。

Article *article1 = [[Article alloc] initWithTitle: @"First Text" Subtitle: @"Data&Time" Thumbnail: [UIImage imageNamed: @"image.png"]]; 
articles = [[NSMutableArray alloc] init]; 
[articles addObject:article1]; 
+0

に画像を表示するカスタムセルを追加し、あなたの質問を言い換えるしようとしてもらえますか?それはあまり明確ではありません。自己完結型サンプルは、問題を理解するのに役立ちます。前もって感謝します。 –

+0

質問を編集する – user1171478

+0

申し訳ありませんが、何をしたいですか?記事配列に含まれる項目をUITableView内に表示しますか?提案がありますか?前もって感謝します。 –

答えて

0

UICellクラスを継承する必要がありますが、あまりにも多くの例があります。 「カスタムUITableView」や「カスタムUITableViewCell」のようなgoogle smthです。

また、ココアの細胞の左画像もあります。

1

Articleオブジェクトのプロパティをセルに表示しますか?セクションが1つしかなく、あなたのUITableViewControllerがすでに「記事」という記事の配列への参照を持っているとしましょう。

- (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]; 
    } 
    Article *article = [articles objectAtIndex:indexPath.row]; 
    cell.textLabel.text = article.title; 
    cell.detailTextLAbel.text = article.subtitle; 
    cell.imageView.image = article.thumbnail; 
    return cell; 
} 
0

テーブルビュー

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
     static NSString *CellIdentifier = @"MoreDetailCell"; 
    MoreDetailCell *cell = (MoreDetailCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"MoreDetailCell" owner:self options:nil]; 
     for (id currentObject in topLevelObjects){ 
      if ([currentObject isKindOfClass:[UITableViewCell class]]){ 
       cell = (MoreDetailCell *)currentObject; 
       break; 




      } 
     } 
    } 
     cell.compImage.image = [UIImage imageNamed:@"Placeholder.png"]; 
     cell.yourtexfieldname.text = @"ABC"; 
} 
関連する問題