SWRevealViewController push from subview

2019-06-13 08:13发布

问题:

I have a LoginView and in success of login I am loading Slideout menu view (SWRevealViewController) .

I am using the following to load reveal view controller with front view(Dashboard) and rear view (slidebarView) !

 AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

                UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];

                SWRevealViewController *viewController1 = (SWRevealViewController *)[mainStoryboard instantiateViewControllerWithIdentifier:@"next"];

                [appDelegate.window setRootViewController:viewController1];

In Rear view where we have menu (Appointments, mystylist ,Barbers , Locate me and Settings ) .

In Settings we have 3 option and 3 different view controller . When i am pushing from settingsViewController to generalViewController, it loads login view controller's method !

I am using this to push !

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

NSLog(@"%@",[List objectAtIndex:indexPath.row]);

//
if (indexPath.row==0) {

    UIStoryboard * storyboard = self.storyboard;
    generalViewController * detail = [storyboard instantiateViewControllerWithIdentifier:@"General"];
    [self.navigationController pushViewController: detail animated: YES];


}
}

Because of this , all method in loginViewController is being called !

Please help me out of this problem . How to push a viewController from frontViewController of revealViewController ?

Thanks in Advance !

回答1:

Follow these steps : suppose From side menu ,user select setting option then write following code in viewDidLoad method of Settingviewcontroller .

Also import SWRevealViewcontroller.h *Note - Side bar button ( a three line image )

//setting side Button Action
    SWRevealViewController *revealVC = self.revealViewController;
    if (revealVC) {
        [sideBarButton addTarget:self.revealViewController action:@selector(revealToggle:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
    }    

//show Setting View Screen 
        SWRevealViewController *svc = self.revealViewController;
        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        UIViewController *homeVC = [storyboard instantiateViewControllerWithIdentifier:@"settingVC"];
        [svc setFrontViewController:homeVC animated:NO];
        [svc revealToggleAnimated:YES];


回答2:

Follow This Steps Too:

  • Connect Login VC to SWRevealVC as MODAL SEGUE [Not having navigation]

  • Add an Identifier to MODAL SEGUE

  • Once SignIn get success,,

    [self performSegueWithIdentifier:@"reveal" sender:self];



回答3:

Please check your viewControllers is of which subClass !

Please check it is of UIViewController's subclass .