我知道无法识别的选择器问题的含义。它总是由于调用一个未实现或未找到的方法。我已经实现了选择器,我也可以看到它。
我仍然收到此错误。我正在使用MFSlideMenu控件。
在用户注销并再次登录之前,它对我很有用。登录后,当用户点击导航栏项目时,我的应用程序崩溃说:
[__NSCFType gestureRecognizer:shouldReceiveTouch:]: unrecognized selector sent to instance 0xc882da0
我正在AppDelegate
设置根控制器,如下所示:
LeftMenuViewController *leftSideMenuController = [[LeftMenuViewController alloc] init];
RightMenuViewController *rightSideMenuController = [[RightMenuViewController alloc] init];
MFSideMenuContainerViewController *container = [MFSideMenuContainerViewController
containerWithCenterViewController:self.meNavigationController
leftMenuViewController:leftSideMenuController
rightMenuViewController:rightSideMenuController];
[[self.meNavigationController.viewControllers lastObject] viewDidLoad];
self.window.rootViewController = container;
[self.window makeKeyAndVisible];
然后,在我的viewController
中,我在navBarItems
方法中根据此控件设置viewDidLoad
。
我在这里设置navBarItems
:
#pragma mark - UIBarButtonItems
- (void)setupMenuBarButtonItems {
self.navigationItem.rightBarButtonItem = [self rightMenuBarButtonItem];
if(self.menuContainerViewController.menuState == MFSideMenuStateClosed &&
![[self.navigationController.viewControllers objectAtIndex:0] isEqual:self]) {
self.navigationItem.leftBarButtonItem = [self backBarButtonItem];
} else {
self.navigationItem.leftBarButtonItem = [self leftMenuBarButtonItem];
}
}
- (UIBarButtonItem *)leftMenuBarButtonItem {
return [[UIBarButtonItem alloc]
initWithImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"reveal-icon.png" ofType:nil]] style:UIBarButtonItemStyleBordered
target:self
action:@selector(leftSideMenuButtonPressed:)];
}
- (UIBarButtonItem *)rightMenuBarButtonItem {
return [[UIBarButtonItem alloc]
initWithImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"reveal-icon.png" ofType:nil]] style:UIBarButtonItemStyleBordered
target:self
action:@selector(rightSideMenuButtonPressed:)];
}
- (UIBarButtonItem *)backBarButtonItem {
return [[UIBarButtonItem alloc] initWithTitle:BACK_BUTTON_NAVIGATION_BAR_BUTTON_STRING style:UIBarButtonItemStylePlain target:nil action:nil];
}
#pragma mark - UIBarButtonItem Callbacks
- (void)backButtonPressed:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}
- (void)leftSideMenuButtonPressed:(id)sender {
[self.menuContainerViewController toggleLeftSideMenuCompletion:^{
[self setupMenuBarButtonItems];
}];
}
- (void)rightSideMenuButtonPressed:(id)sender {
[self.menuContainerViewController toggleRightSideMenuCompletion:^{
[self setupMenuBarButtonItems];
}];
}