我想使用选择器来访问我的控制器并传递2个值,即发送者和数字。
问题是我得到了崩溃:
***由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:' - [CDCFaderController changeView:]:无法识别的选择器发送到实例0x109db6f40'
代码对我有意义,所以不确定为什么,任何人都能帮忙?
[self.viewController performSelector:@selector(changeView:) withObject:self withObject:[NSNumber numberWithInteger: channel.channelNumber]];
接收器:
- (void)changeView:(UIButton *)sender chanToPush:(NSNumber*)channel
答案 0 :(得分:3)
选择器错误。 @selector(changeView:)
应为@selector(changeView:chanToPush:)
。
试试这个。
[self.viewController performSelector:@selector(changeView:chanToPush:) withObject:self withObject:[NSNumber numberWithInteger: channel.channelNumber]];
答案 1 :(得分:0)
直接使用
[self performSelector:@selector(changeView:chanToPush:) withObject:self withObject:[NSNumber numberWithInteger: channel.channelNumber]];
- (void)changeView:(UIButton *)sender chanToPush:(NSNumber*)channel
{
NSLog(@"channel is --%@",channel);
}
或强>
[self performSelector:@selector(changeView:) withObject:[NSNumber numberWithInteger: channel.channelNumber]];
- (void) changeView:(NSNumber *)num
{ //
}