2

我遇到了这个异常,我很清楚为什么会这样:

2013-08-10 06:23:21.417  Unknown class login in Interface Builder file.
2013-08-10 06:23:41.714 [HomeViewController revealMenu]: unrecognized selector sent to instance 0x7145bf0
2013-08-10 06:23:41.716 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[HomeViewController revealMenu]: unrecognized selector sent to instance 0x7145bf0'
*** First throw call stack:
(0x1394012 0x115ce7e 0x141f4bd 0x1383bbc 0x138394e 0x1170705 0xa42c0 0xa4258 0x165021 0x16557f 0x1646e8 0xd3cef 0xd3f02 0xb1d4a 0xa3698 0x2235df9 0x2235ad0 0x1309bf5 0x1309962 0x133abb6 0x1339f44 0x1339e1b 0x22347e3 0x2234668 0xa0ffc 0x252d 0x2455 0x1)
libc++abi.dylib: terminate called throwing an exception

似乎通知我 HomeViewController 中缺少revealMenu 方法,但它就在那里

- (void)viewDidLoad
{
    ....
    [self.btnLeft addTarget:self action:@selector(revealMenu) forControlEvents:UIControlEventTouchUpInside];
    ....
}


-(IBAction)revealMenu:(id)sender
{
    [self.slidingViewController anchorTopViewTo:ECRight];
}
4

1 回答 1

7

revealMenu并且revealMenu:是两个不同的选择器,而您正在调用一个不存在的选择器,从而导致崩溃。用这个替换你的代码,它应该可以工作。(在选择器末尾添加冒号)

[self.btnLeft addTarget:self action:@selector(revealMenu:) forControlEvents:UIControlEventTouchUpInside];

冒号指定一个参数,所以...

-(IBAction)revealMenu

有一个选择器revealMenu

-(IBAction)revealMenu:(id)sender

有一个选择器revealMenu:

-(IBAction)revealMenu:(id)sender andSome:(NSObject *)otherArgument

有一个选择器revealMenu:andSome:

于 2013-08-10T15:05:56.140 回答