0

CustomCell にあるボタンをクリックすると、アラートが表示されるようにしたい CustomCell があります。そのCustomCellのメソッドにアクセスする方法

  @interface CustomCell : UITableViewCell {

IBOutlet UIImageView    *imageViewCell;
IBOutlet UILabel        *theTitle;
IBOutlet UIButton*imageButton;


  }

  @property(nonatomic,retain) IBOutlet UIButton*imageButton;
  @property(nonatomic,retain) UIImageView *imageViewCell;
  @property(nonatomic,retain) UILabel *theTitle;

 -(IBAction)imageButtonAction;

 @end



     @implementation CustomCell

     @synthesize imageViewCell;
     @synthesize theTitle;

    -(IBAction)imageButtonAction{


     }

ここでこのメソッドを呼び出す代わりに、CustomCell を使用しているクラスでこのメソッドを呼び出す必要があります。

4

3 に答える 3

2

あなたのcellForRowAtIndexPath追加でこのコード:

[cell.imageButton addTarget:self action:@selector(imageButtonAction) forControlEvents:UIControlEventTouchUpInside];

-(IBAction)imageButtonAction;このカスタマイズされたセルを使用している特定のクラスで、この関数を宣言して定義します。

于 2013-03-05T10:20:44.380 に答える
1

セルを指定した後、インデックス パスの cellforrow に以下の行を追加します。セル内のボタンをクリックすると、メソッドが呼び出されます

[cell.button addTarget:self action:@selector(imageButtonAction) forControlEvents:UIControlEventTouchUpInside];
于 2013-03-05T10:21:07.467 に答える
0

cellforrowatindexpath: メソッドで以下の行を使用します

[cell.imageButton addTarget:self action:@selector(imageButtonAction) forControlEvents:UIControlEventTouchUpInside];

imageButtonAction のメソッドを作成することを忘れないでください

于 2013-03-05T10:32:22.187 に答える