ios - Objective-c : addTarget to UIButton not calling -


i tried use addtarget add event uibutton this

egoimagebutton* image = [[egoimagebutton alloc] initwithplaceholderimage:[uiimage imagenamed:@"screen.png"]];     [image setimageurl:[nsurl urlwithstring:thumbnail]];     [image setframe:cgrectmake(x, y, self.cellsize, self.cellsize)];     [image settag: [self.photoids count]-1];     [image addtarget:self action:@selector(buttontouched:) forcontrolevents:uicontroleventtouchupinside];     [self.view addsubview:image];     [image release]; 

the function definition this:

-(void)buttontouched:(id)sender {    nslog(@"thumbnail clicked");  } 

this code egoimagebutton init function

- (id)initwithplaceholderimage:(uiimage*)animage { return [self initwithplaceholderimage:animage delegate:nil];    }  - (id)initwithplaceholderimage:(uiimage*)animage delegate:(id<egoimagebuttondelegate>)adelegate { if((self = [super initwithframe:cgrectzero])) {     self.placeholderimage = animage;     self.delegate = adelegate;     [self setimage:self.placeholderimage forstate:uicontrolstatenormal]; }  return self; 

}

error looking this:

-[nscftype buttontouched:]: unrecognized selector sent instance 0x6c804a0 2012-06-06 01:36:59.061 photo collage facebook[2416:16103] * terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[__nscftype buttontouched:]: unrecognized selector sent instance 0x6c804a0' * call stack @ first throw: ( 0 corefoundation 0x0046a5a9 __exceptionpreprocess + 185 1 libobjc.a.dylib 0x01402313 objc_exception_throw + 44 2 corefoundation 0x0046c0bb -[nsobject(nsobject) doesnotrecognizeselector:] + 187 3 corefoundation 0x003db966 __forwarding + 966 4 corefoundation 0x003db522 _cf_forwarding_prep_0 + 50

it's bit strange doesn't called, since seens set correctly (https://stackoverflow.com/questions/8968446/cant-able-to-add-click-event-in-uibutton reference ). first guess, without have access code, above image , hence click event not passed uibutton sub-class (egoimagebutton).


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -