0
votes

Hey all , i've got a simple UIView, with a UIButton inside of that, calling a method, i've tried to simplify it as much as possible but am constantly running into the same error:

2011-02-25 10:33:23.423 USOpenTimeLine[21288:207] -[CALayer buttonClicked:]: unrecognized selector sent to instance 0x4d2a020 2011-02-25 10:33:23.425 USOpenTimeLine[21288:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CALayer buttonClicked:]: unrecognized selector sent to instance 0x4d2a020' * Call stack at first throw:

my code is as follows:

-(UIView *)createView:(NSArray *)_data{

    UIView *_view = [[UIView alloc ] initWithFrame:CGRectMake(0, 0, 1024, 768)];
    pageData = [[NSMutableArray alloc] init]; 
    self.imageData = _data;
    [_view setBackgroundColor:[UIColor colorWithRed:1.0 green:1.0 blue:0 alpha:1.0]];
    [self addSubview:_view];

    UIButton *_button1= [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
    _button1.frame = CGRectMake(110.0, 360.0, 100.0, 30.0);
    [_button1 setTitle:@"Play" forState:UIControlStateNormal];
    _button1.backgroundColor = [UIColor clearColor];
    [_button1 addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
    [_view addSubview:_button1];  

    [_button1 release];
    [_view release];

    return _view;
}

- (IBAction)buttonClicked:(id)sender
{
    NSLog(@"Hi!");
}

I can't for the life of me figure out what is going on here... Any help or insight would be greatly appreciated! Thanks

1
ok, i figured it out, i was releasing the parent view too early.FlashGuy13

1 Answers

0
votes

This code looks correct. Most likely you have a memory management issue and the object that created this button and implemented the buttonClick: method is gone, and the memory is now occupied by some new object that doesn't implement buttonClicked.

Turn on zombie checking; that should help you track down the problem.