我收到此异常,并且我很清楚为什么会这样:

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];
}

最佳答案

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

[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:的选择器

关于objective-c - 我无法翻译此异常(exception)。如何解决?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18163147/

10-13 01:34