I am trying to make a two-button view for the accessory view of a table cell in order to do two (obviously) different things for the object in this cell index. I made two main rounded rectangular UIButtons with a selector in the RootViewController (where the UITableView is located). Here is the code that I use to initialize this view in a cell that is in the cellForRowAtIndexPath method:
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];
And two methods that they call are defined:
- (void)subtractOne:(id)sender forEvent:(UIEvent *)event;
- (void)addOne:(id)sender forEvent:(UIEvent *)event;
Any ideas why this would cause an unrecognized sender to send an instance of "RootViewController"?
Here is the complete error:
2011-03-20 20: 34: 35.493 MyApp [23262: 207] - [RootViewController subtractOne: event:]: , 0x573c350
2011-03-20 20: 34: 35.496 MyApp [23262: 207] * - "NSInvalidArgumentException", : '- [RootViewController subtractOne: event:]: , 0x573c350'