嘿,我已經有了一個簡單的UIView,裏面有一個UIButton,調用了一個方法,我試圖儘可能簡化它,但我一直在運行同樣的錯誤:發送到實例的無法識別的選擇器 - UIButton操作
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:
我的代碼如下:
-(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!");
}
我不能爲我的生活弄清楚是怎麼回事... 任何幫助或洞察力將不勝不勝感激! 謝謝
好吧,我想通了,我太早發佈父視圖。 – FlashGuy13 2011-02-25 15:51:14