在我的应用程序中,我有一个在屏幕上滚动的动画。我的问题是,当我使用 an@selector
调用我的动画时,线程崩溃了。
如果我使用相同@selector
的方法在我的页面中调用另一个函数,它可以完美运行,但是当调用这个函数时它似乎不起作用。如果我将代码放在该viewDidLoad
部分中,它可以正常工作。
unrecognized selector sent to instance
我在 Stackoverflow中尝试了很多这样的链接,但没有任何帮助。我也尝试- (void)imageSpawn
了代替 - (void) imageSpawn:(id)sender withEvent:(UIEvent *)
事件并将选择器更改为(imageSpawn)
而不是`(ImageSpawn :)仍然没有运气......
- (void)viewDidLoad {
[self performSelector:@selector(imageSpawn:) withObject:nil afterDelay:3];
}
- (void) imageSpawn:(id) sender withEvent:(UIEvent *) event
{
UIImage* image = [UIImage imageNamed:@"ae"];
UIImageView *rocket = [[UIImageView alloc] initWithImage:image];
rocket.frame = CGRectMake(-25, 200, 25, 40);
[UIView animateWithDuration:5 animations:^(){rocket.frame=CGRectMake(345, 200, 25, 40);} completion:^(BOOL finished){if (finished){
//trigger an event.
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Tapped row!"
message:[NSString stringWithFormat:@"Shot"]
delegate:nil
cancelButtonTitle:@"Yes, I did!"
otherButtonTitles:nil];
[alert show];
}
}];
[myScrollView addSubview:rocket];
}
2013-03-28 10:14:31.661 shotplacementgiude001[16897:c07] -[SelectedCellViewController imageSpawn:]: unrecognized selector sent to instance 0xa159480
2013-03-28 10:14:31.663 shotplacementgiude001[16897:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SelectedCellViewController imageSpawn:]: unrecognized selector sent to instance 0xa159480'
*** First throw call stack:
(0x16b4012 0x13c1e7e 0x173f4bd 0x16a3bbc 0x16a394e 0xdbf5b3 0x1673376 0x1672e06 0x165aa82 0x1659f44 0x1659e1b 0x27157e3 0x2715668 0x305ffc 0x2c3d 0x2b65 0x1) libc++abi.dylib: terminate called throwing an exception
(lldb)