我得到了这个例外,我很清楚为什么会发生这种情况:
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];
}
答案 0 :(得分: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: