テーブル セル アクセサリ ビューの 2 つのボタンを使用して、そのセル インデックスのオブジェクトに対して 2 つの (明らかに) 異なることを行うビューを作成しようとしています。RootViewController (UITableView が存在する場所) のセレクターを使用して、2 つの基本的な丸みを帯びた四角形の UIButton を作成しました。cellForRowAtIndexPath メソッドで見つかったセルでこのビューを初期化するために使用するコードを次に示します。
UIButton* minus = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
[minus setFrame:CGRectMake(0, 0, 30, 30)];
[minus setTitle:@"-" forState:UIControlStateNormal];
[minus addTarget:self action:@selector(subtractOne:event:) forControlEvents:UIControlEventTouchDown];
UIButton* plus = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
[plus setFrame:CGRectMake(30, 0, 30, 30)];
[plus setTitle:@"+" forState:UIControlStateNormal];
[plus addTarget:self action:@selector(addOne:event:) forControlEvents:UIControlEventTouchDown];
UIView* customAccessory = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 60, 30)];
[customAccessory addSubview:minus];
[customAccessory addSubview:plus];
cell.accessoryView = customAccessory;
[customAccessory release];
そして、それらが呼び出す 2 つのメソッドが定義されています。
- (void)subtractOne:(id)sender forEvent:(UIEvent *)event;
- (void)addOne:(id)sender forEvent:(UIEvent *)event;
インスタンス「RootViewController」に送信された認識できない送信者がスローされる理由はありますか?
完全なエラーは次のとおりです。
2011-03-20 20:34:35.493 MyApp[23262:207] -[RootViewControllersubtractOne:event:]: インスタンス 0x573c350 に送信された認識されないセレクター 2011-03-20 20:34:35.496 MyApp[23262:207] * appinating の終了例外 'NSInvalidArgumentException' がキャッチされていないため、理由: '-[RootViewControllersubtractOne:event:]: 認識されないセレクターがインスタンス 0x573c350 に送信されました'