2016-07-27 14 views
0

こんにちは、私はiOSの初心者です。Image of Tableviewセル

私はViewController1でテーブルビューを実装しました。テーブルビューでは、セルのtittle、detailText、およびdisclosureインジケータを表示しています。

- (UITableViewCell *)tableView:(UITableView *)tableView 
    cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
static NSString *MyIdentifier = @"MyIdentifier"; 

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; 

if (cell == nil) 
{ 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 
            reuseIdentifier:MyIdentifier]; 
} 



cell.textLabel.text =[listTableArray objectAtIndex:indexPath.row]; 
cell.textLabel.textColor=[UIColor grayColor]; 
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 

    [email protected]"4mile"; 





return cell; 
} 

すべてが今、私は私がすることなく、開示インジケーターと一緒に、両方の画像を必要とするimage.Butに置き換えられ

UIImageView *accessoryView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)]; 
    accessoryView.image=[UIImage imageNamed:@"list.png"]; 
cell.accessoryView = accessoryView; 

ディスクロージャー・インジケータでそれを行う際に開示インジケーター前の画像を必要とし、正常に動作しますカスタムセルを使用します。

どうすればいいですか?私を助けてください。

おかげ

enter image description here

あなたがあなたのimageViewセルのcontentViewとに追加する必要がある標準UITableViewCellUIImageViewを追加したい場合は、私がイメージ

+0

を試みるところ本当にカスタムセル – Birendra

+1

を表示するためにスクリーンショットを提供してくださいスクリーンショット –

+0

@Birendra追加すべき画像 – remyr3my

答えて

0

UITableViewCellを実装し、あなたがそれを初期化するときに使用するスタイルに応じて、固定レイアウトを持っています。そのレイアウトを変更することはできません。なぜなら、セルはサブビューを持っているからです。

このようなあなたのセルのサブクラスに- (void)layoutSubviewsを追加します。それ以外の

- (void)layoutSubviews { 
    [super layoutSubviews]; 
    self.imageView.frame = CGRectMake(0.0f , 0.0f, 20.0f, 20.0f); 
} 

この

UIImageView *imageView = [[UIImageView alloc] init]; 
imageView.image = [UIImage imageNamed:@"list.png"];; 
[imageView setFrame:CGRectMake(50, 5, 20, 20)]; // customize the frame 
[cell.contentView addSubview:imageView]; 
+0

@ Anbu anna私はそれがセルの詳細テキスト上でオーバーラップするフレームをカスタマイズしようとしました。 – remyr3my

+0

@ Cyph3r - 次にx座標を変更して試してみてください。 –

+0

@ Anbu x値を変更しようとしましたが、x値が表示されているときに詳細テキストと公開矢印の間に画像が必要です。 – remyr3my

0

を必要とする期日までが、時間の場所に似textLabeldetailTextLabelaccessoryView

UIImageView *accessoryImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)]; 
accessoryImageView.image=[UIImage imageNamed:@"list.png"]; 
[cell.contentView addSubview:accessoryImageView]; 
01のようなすべてのサブビューを追加します

またはUITableViewCellのサブクラスとその内部のすべてのビュー

+0

その動作していません – remyr3my

+0

イメージは表示されませんか?またはクラッシュした – iSashok

+0

画像は公開されていますが開示されていません – remyr3my

関連する問題