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

revealMenurevealMenu:は 2 つの異なるセレクターであり、存在しないセレクターを呼び出しているため、クラッシュが発生します。コードをこれに置き換えると、動作するはずです。(セレクターの最後にコロンを追加)

[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 に答える