-2

次のようなカスタム セル ボタンで addTarget を使用しています。

[cell.btnGet addTarget:self action:@selector(getLocal:cell:) forControlEvents:UIControlEventTouchUpInside];

このメソッドを呼び出す必要があります。

-(void)getLocal:(id)sender withcell:(GroupListCell *)cell
{
    // code for implement
}

しかし、ボタンをクリックすると、次のようなエラーがスローされます。

2013-02-27 14:28:56.533 iOSPlayer[704:11303] -[GroupView getLocal:cell:]: unrecognized selector sent to instance 0x72e1290
2013-02-27 14:28:56.534 iOSPlayer[704:11303] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GroupView getLocal:cell:]: unrecognized selector sent to instance 0x72e1290'

ここでの問題は何ですか?

4

2 に答える 2

1

そのアクションメソッドは次のように呼び出されます。

getLocal:withcell:

ではなく:

getLocal:cell:

また、次のような許容可能なアクションメソッドシグネチャのいずれとも一致しません。

- (IBAction)doSomething;
- (IBAction)doSomething:(id)sender;
- (IBAction)action:(id)sender forEvent:(UIEvent *)event;

(このAppleガイドを参照してください)

于 2013-02-27T09:09:43.400 に答える
1

これを試して:

[cell.btnGet addTarget:self action:@selector(getLocal:withcell:) forControlEvents:UIControlEventTouchUpInside];
于 2013-02-27T09:08:32.947 に答える