So, I’m trying to programmatically attach event handlers to widgets I’ve placed on my iphone application using:
addTarget:action:forControlEvents
I have added a UISegmentedControl in Interface Builder which is exposed through @property seg and in loadView, I have:
- (void)loadView
{
[ super loadView ] ;
//k after that attach our own event handlers
[ seg addTarget:seg action:@selector(sliderEventIB) forControlEvents:UIControlEventAllEvents ];
}
sliderEventIB, just tells us it feels the event:
-(IBAction)sliderEventIB:(id)sender forEvent:(UIEvent*)event
{
puts( "I feel you joanna" ) ;
}
but the error I’m getting is
ViewControllersTest[6744:207] *** -[UISegmentedControl sliderEventIB]: unrecognized selector sent to instance 0x3b21b30
Any idea what it doesn’t like here?
It seems like you just forgot to insert the colon in addTarget:
[ seg addTarget:seg action:@selector(sliderEventIB:) forControlEvents:UIControlEventAllEvents ];
It should be sliderEventIB: not sliderEventIB.