Switching views with ECSliding without navigation menu

旧街凉风 提交于 2019-12-24 01:49:09

问题


I'm using ECSlidingViewController.

In the sample project i added a button on the First view with an IBAction
I want the button on the First view to go to the second view (without using the slide out navigation).

- (IBAction)btnPressed:(id)sender {
    UIViewController *newTopViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"SecondTop"];
    [self.slidingViewController anchorTopViewOffScreenTo:ECRight animations:nil onComplete:^{
        CGRect frame = self.slidingViewController.topViewController.view.frame;
        self.slidingViewController.topViewController = newTopViewController;
        self.slidingViewController.topViewController.view.frame = frame;
        [self.slidingViewController resetTopView];
    }];
}

With this code it only goes to the navigation slide out menu and doesn't go to the Second


回答1:


Don't always use self.slidingViewController. It's a derived property, not a static value. So what's happening is that you replace the first view with the second view and then the first view can't get the sliding controller any more (you broke its reference). So, do this instead:

- (IBAction)btnPressed:(id)sender {
    ECSlidingViewController *slidingViewController = self.slidingViewController;

    UIViewController *newTopViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"SecondTop"];
    [slidingViewController anchorTopViewOffScreenTo:ECRight animations:nil onComplete:^{
        CGRect frame = slidingViewController.topViewController.view.frame;
        slidingViewController.topViewController = newTopViewController;
        slidingViewController.topViewController.view.frame = frame;
        [slidingViewController resetTopView];
    }];
}


来源:https://stackoverflow.com/questions/17277606/switching-views-with-ecsliding-without-navigation-menu

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