SWRevealViewController back to previous viewcontroller not working

最后都变了- 提交于 2020-01-16 03:57:04

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!