-1

SELボタンセレクターに設定したい変数があります。

私のコードは次のようになります。

GridView *ObjGridView=[[GridView alloc]initWithFrame:frame]; 
[[NSBundle mainBundle ] loadNibNamed:@"GridView" owner:ObjGridView options:nil];

CATEGORY *ObjCategory=[arrCategory objectAtIndex:index];
//do something 

ICON *ObjIcno=[ObjCategory.arrIconObjects objectAtIndex:indexIcon];

[ObjGridView.button1 addTarget:self action:ObjIcno.handler forControlEvents:UIControlStateNormal];

ObjIcno.handlerSEL 変数です (これは、以前に selector によって設定されています)

このような:

arrSectonProductivityTools=[NSMutableArray arrayWithObjects:[[[ICON alloc]initWithIcon:@"firefox.png":@"Firefox":@selector(FirefoxCickEvent:)] autorelease],nil];

この方法でクラスにセレクターを設定しましたが、これは正しく設定されていますが、クリックイベントが発生しません。

4

1 に答える 1

1
[ObjGridView.button1 addTarget:self action:ObjIcno.handler forControlEvents:UIControlStateNormal];

次のようにする必要があります。

[ObjGridView.button1 addTarget:self action:ObjIcno.handler forControlEvents:UIControlEventTouchUpInside];

UIControlEventTouchUpInside 以外のオプションについては、UIControlEventTouchUpInside で cmd + マウス クリックを実行します。

于 2012-05-29T13:35:04.847 に答える