Lie*_*-An 6 transition controller ios
我已经找到了几个关于此的问题,但答案并没有解决我的问题.
我有两个使用presentModalViewController呈现的控制器.
我将modalTransitionStyle添加到主控制器调用的第一个控制器.第一个控制器正常显示第二个控制器(没有过渡样式).
FirstVC *first = [[FirstVC alloc] initWithNibName:@"FirstVC" bundle:nil];
first.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentModalViewController:first animated:YES];
SecondVC *second = [[SecondVC alloc] initWithNibName:@"SecondVC" bundle:nil];
[self presentModalViewController:second animated:YES];
Run Code Online (Sandbox Code Playgroud)
这是我以前用于MainVC的代码:
[self.presentingViewController.presentingViewController dismissModalViewControllerAnimated:YES];
Run Code Online (Sandbox Code Playgroud)
这就是发生的事情:

页面没有解开.我遇到这个的原因是什么?
在我的实验,似乎你不能有部分卷曲后有标准(盖垂直),并同时驳回他们两个,除非你做开除设置为NO动画.
解决这个问题的方法是解除没有动画的secondVC(此代码在secondVC中):
-(IBAction)dismissSelf:(id)sender {
[self dismissViewControllerAnimated:NO completion:nil];
}
Run Code Online (Sandbox Code Playgroud)
然后在firstDC中再次使用动画解除viewDidAppear,在测试控制器未显示之后:
-(void)viewDidAppear:(BOOL)animated {
if (![self isBeingPresented]) {
[self dismissViewControllerAnimated:YES completion:nil];
}
}
Run Code Online (Sandbox Code Playgroud)
虽然上面的代码可以回到初始控制器的视图,但您会看到firstVC的视图出现在curl uncurls之前.如果你不想看到它,那么我找到解决这个问题的唯一方法就是创建一个secondVC的图像,在解除secondVC之前将其作为(在图像视图中)添加到firstVC.所以,要做到这一点,secondVC中的代码应该是这样的(请注意,您必须链接到QuartzCore并将其导入secondVC才能使其工作):
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
UIImage *img = [self imageWithView:self.view];
FirstViewController *first = (FirstViewController *)self.presentingViewController;
UIImageView *iv = [[UIImageView alloc] initWithFrame:first.view.bounds];
iv.image = img;
[first.view addSubview:iv];
}
-(IBAction)dismissSelf:(id)sender {
[self dismissViewControllerAnimated:NO completion:nil];
}
- (UIImage *)imageWithView:(UIView *)view {
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, [[UIScreen mainScreen] scale]);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
Run Code Online (Sandbox Code Playgroud)
您应该通过以下调用依次表达您的两种观点:
[self presentViewController:firstViewController animated:YES completion:^(
[self presentViewController:secondViewController animated:YES completion:^(
}];
}];
Run Code Online (Sandbox Code Playgroud)
这应该表现得更好。另外,要知道之后您必须将这两个 viewController 关闭。
[self.presentingViewController.presentingViewController dismissViewControllerAnimated:YES completion:^{
[self.presentingViewController.presentingViewController dismissViewControllerAnimated:YES completion:^{
}];
}];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4843 次 |
| 最近记录: |