问题
I'm using SWRevealViewController and I'm trying to implement a back button
there's my code to go to another view:
- (IBAction)goViewController:(id)sender {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UINavigationController *topViewController = [storyboard instantiateViewControllerWithIdentifier:@"globalFIndAutoCompleteID"];
[self.revealViewController pushFrontViewController:topViewController animated:YES];
}
and my backbutton code:
- (IBAction)backClick:(UIButton *)sender {
[SVProgressHUD dismiss];
[self.revealViewController.navigationController popViewControllerAnimated:YES];
}
回答1:
I solved my problem replacing the code with the following:
-(void) goViewController:(UIButton *)sender{
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
appDelegate.previousController = self;
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UINavigationController *topViewController = [storyboard instantiateViewControllerWithIdentifier:@"globalFIndAutoCompleteID"];
[self.revealViewController presentViewController:topViewController animated:YES completion:nil];
}
- (IBAction)backClick:(UIButton *)sender {
[SVProgressHUD dismiss];
[self dismissViewControllerAnimated:YES completion:^{}];
}
来源:https://stackoverflow.com/questions/35363570/swrevealviewcontroller-back-to-previous-viewcontroller-not-working