我正在使用ECSliding,但是我有这个问题!
在我的项目中有以下文件:
InitViewController (ECSlidingController)
FirstViewController (UIViewController)
SecondViewController (UIViewController)
LeftMenuViewController (UIViewController)
LeftMenuTwoViewController (UIViewController)
我使用InitView将FirstView设置为topview。
向右滑动将显示LeftMenuViewController,该按钮具有一个按钮,如果按下该按钮,则将topview更改为SecondViewController。我想知道是否可以将LeftMenuTwoViewController用作SecondView的underLeftViewController。我也想在LeftMenuTwo中将topView更改为FirstView的按钮。
我想要一个带有UnderLeftViewController作为LeftMenuViewController的FirstView,和一个带有underLeftViewController作为LeftMenuTwoViewController的SecondView。每个菜单都有一个按钮,用于将topView更改为具有不同的underLeftViewController的另一个菜单。
我这样做:
SecondViewController *second = [self.storyboard
instantiateViewControllerWithIdentifier:@"SecondTop"];
[self.slidingViewController anchorTopViewOffScreenTo:ECRight
animations:nil
onComplete:^{
self.slidingViewController.topViewController = second;
[self.slidingViewController resetTopViewWithAnimations:nil
onComplete:^{
LeftMenuTwoViewController *newUnderLeftVC = [self.storyboard
instantiateViewControllerWithIdentifier:@"LeftTwo"];
self.slidingViewController.underLeftViewController = newUnderLeftVC;
}];
}];
但是,当我按下按钮时,topView通过向右滑动开始弹跳动画,但是再也不会回来,并且在TopView离开屏幕后,underLeftViewController立刻变为空白。有人知道为什么吗?
下载:My Project
最佳答案
将方法更改为此:
-(IBAction)openSecond:(id)sender
{
SecondViewController *second = [self.storyboard instantiateViewControllerWithIdentifier:@"Second"];
ECSlidingViewController *slideController = self.slidingViewController;
[slideController anchorTopViewOffScreenTo:ECRight animations:nil onComplete:^{
slideController.topViewController = second;
[slideController resetTopViewWithAnimations:nil onComplete:^{
LeftMenuTwoViewController *newUnderLeftVC = [self.storyboard instantiateViewControllerWithIdentifier:@"LeftTwo"];
slideController.underLeftViewController = newUnderLeftVC;
}];
}];
}
问题在于,当视图将其自身删除为顶部视图控制器时,调用
self.slidingViewController
不再返回有效实例(它返回nil)。