SWRevealViewController菜单按钮仅在第一次加载视图时有效。但是,只要单击搜索按钮,它就不会再滑出。在调试过程中,我尝试将搜索按钮的功能更改为重新加载功能,以便进行测试。然后我发现我仍然在菜单按钮中遇到同样的错误。它从未滑出。
以下是搜索按钮和菜单按钮的代码。
//Original Code
_searchButton.layer.cornerRadius = 5;
_searchButton.layer.masksToBounds = YES;
[_searchButton addTarget:self action:@selector(searchHospital) forControlEvents:UIControlEventTouchDown];
//Modified Code
_searchButton.layer.cornerRadius = 5;
_searchButton.layer.masksToBounds = YES;
[_searchButton addTarget:self action:@selector(reloadThisView) forControlEvents:UIControlEventTouchDown];
//definition for reloadThisView
- (void)reloadThisView {
[self viewDidLoad];
}
//code for Menu bar button item; in viewDidLoad
SWRevealViewController *revealController = [self revealViewController];
UIImage *myImage = [UIImage imageNamed:@"menu-tab.png"];
myImage = [myImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIBarButtonItem *rightRevealButtonItem = [[UIBarButtonItem alloc] initWithImage:myImage style:UIBarButtonItemStylePlain target:revealController action:@selector(rightRevealToggle:)];
self.navigationItem.rightBarButtonItem = rightRevealButtonItem;
UIBarButtonItem * item = [[UIBarButtonItem alloc] initWithCustomView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"new-logo"]]];
self.navigationItem.leftBarButtonItem = item;
现在的问题是;在SWRevealViewController类上运行菜单按钮会出现故障的可能原因是什么?